Remove-Event
從事件佇列中刪除事件。
Syntax
Remove-Event
[-SourceIdentifier] <String>
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Remove-Event
[-EventIdentifier] <Int32>
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
Cmdlet Remove-Event
會從目前會話中的事件佇列中刪除事件。
這個 Cmdlet 只會刪除目前在佇列中的事件。 若要取消事件註冊或取消訂閱,請使用 Unregister-Event
Cmdlet。
範例
範例 1︰依來源識別碼移除事件
PS C:\> Remove-Event -SourceIdentifier "ProcessStarted"
這個命令會從事件佇列中刪除來源識別碼為 Process Started 的事件。
範例 2︰依事件識別碼移除事件
PS C:\> Remove-Event -EventIdentifier 30
這個命令會從事件佇列中刪除事件識別碼為 30 的事件。
範例 3:移除所有事件
PS C:\> Get-Event | Remove-Event
這個命令會從事件佇列中刪除所有事件。
參數
-Confirm
在執行 Cmdlet 前提示您確認。
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-EventIdentifier
指定 Cmdlet 要刪除之事件的事件識別碼。 每個命令都需要 EventIdentifier 或 SourceIdentifier 參數。
Type: | Int32 |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-SourceIdentifier
指定此 Cmdlet 從中刪除事件之來源的來源識別碼。 不允許使用萬用字元。 每個命令都需要 EventIdentifier 或 SourceIdentifier 參數。
Type: | String |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-WhatIf
顯示執行 Cmdlet 後會發生的情況。 Cmdlet 並不會執行。
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
輸入
您可以使用管線將事件從 Get-Event
傳送至 Remove-Event
。
輸出
None
此 Cmdlet 不會產生任何輸出。
備註
Linux 或macOS平台上沒有可用的事件來源。
事件、事件訂閱與事件佇列僅存在目前工作階段中。 若關閉目前工作階段,便會捨棄事件佇列,並取消事件訂閱。