Remove-Event
从事件队列中删除事件。
语法
BySource (默认值)
Remove-Event
[-SourceIdentifier] <String>
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ByIdentifier
Remove-Event
[-EventIdentifier] <Int32>
[-WhatIf]
[-Confirm]
[<CommonParameters>]
说明
Remove-Event
cmdlet 命令用于从当前会话中的事件队列中删除事件。
此 cmdlet 仅删除当前位于队列中的事件。 若要取消事件注册或取消订阅,请使用 Unregister-Event
cmdlet。
示例
示例 1:按源标识符删除事件
PS C:\> Remove-Event -SourceIdentifier "ProcessStarted"
此命令删除事件队列中具有“Process Started”源标识符的事件。
示例 2:按事件标识符删除事件
PS C:\> Remove-Event -EventIdentifier 30
此命令从事件队列中删除事件 ID 为 30 的事件。
示例 3:删除所有事件
PS C:\> Get-Event | Remove-Event
此命令从事件队列中删除所有事件。
参数
-Confirm
在运行 cmdlet 之前,提示你进行确认。
参数属性
类型: | SwitchParameter |
默认值: | False |
支持通配符: | False |
不显示: | False |
别名: | cf |
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-EventIdentifier
指定要由 cmdlet 删除的事件标识符。 每个命令都需要 EventIdentifier 或 SourceIdentifier 参数。
参数属性
类型: | Int32 |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
ByIdentifier
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | True |
来自剩余参数的值: | False |
-SourceIdentifier
指定此 cmdlet 将从中删除事件的来源标识符。 不允许使用通配符。 每个命令都需要 EventIdentifier 或 SourceIdentifier 参数。
参数属性
类型: | String |
默认值: | None |
支持通配符: | False |
不显示: | False |
参数集
BySource
Position: | 0 |
必需: | True |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
-WhatIf
显示 cmdlet 运行时会发生什么情况。 命令脚本未运行。
参数属性
类型: | SwitchParameter |
默认值: | False |
支持通配符: | False |
不显示: | False |
别名: | 无线 |
参数集
(All)
Position: | Named |
必需: | False |
来自管道的值: | False |
来自管道的值(按属性名称): | False |
来自剩余参数的值: | False |
CommonParameters
此 cmdlet 支持通用参数:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 有关详细信息,请参阅 about_CommonParameters。
输入
PSEventArgs
可以通过管道将事件从 Get-Event
传递给此 cmdlet。
输出
None
此 cmdlet 不返回任何输出。
备注
Linux 或 macOS 平台上没有可用的事件源。
事件、事件订阅和事件队列仅存在于当前会话中。 如果关闭当前会话,事件队列将被丢弃,事件订阅也将被取消。