共用方式為


Remove-Event

從事件佇列中刪除事件。

語法

BySource (預設值)

Remove-Event
    [-SourceIdentifier] <String>
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ByIdentifier

Remove-Event
    [-EventIdentifier] <Int32>
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

Remove-Event Cmdlet 會從目前會話中的事件佇列中刪除事件。

此 Cmdlet 只會刪除佇列中目前的事件。 若要取消事件註冊或取消訂閱,請使用 Unregister-Event Cmdlet。

範例

範例 1:依來源標識碼移除事件

PS C:\> Remove-Event -SourceIdentifier "ProcessStarted"

此命令會刪除事件,其中包含從事件佇列啟動之進程的來源標識碼。

範例 2:依事件標識碼移除事件

PS C:\> Remove-Event -EventIdentifier 30

此命令會從事件佇列中刪除事件標識碼為 30 的事件。

範例 3:移除所有事件

PS C:\> Get-Event | Remove-Event

此命令會從事件佇列中刪除所有事件。

參數

-Confirm

在執行 Cmdlet 之前,提示您進行確認。

參數屬性

類型:SwitchParameter
預設值:False
支援萬用字元:False
不要顯示:False
別名:cf

參數集

(All)
Position:Named
必要:False
來自管線的值:False
來自管線按屬性名稱的值:False
來自剩餘引數的值:False

-EventIdentifier

指定 Cmdlet 刪除的事件識別碼。 每個命令都需要 EventIdentifierSourceIdentifier 參數。

參數屬性

類型:Int32
預設值:None
支援萬用字元:False
不要顯示:False

參數集

ByIdentifier
Position:0
必要:True
來自管線的值:False
來自管線按屬性名稱的值:True
來自剩餘引數的值:False

-SourceIdentifier

指定此 Cmdlet 從中刪除事件的來源識別碼。 不允許通配符。 每個命令都需要 EventIdentifierSourceIdentifier 參數。

參數屬性

類型: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平台上沒有可用的事件來源。

事件、事件訂閱和事件佇列只存在於當前會話中。 如果您關閉當前的會話,事件佇列將被丟棄,事件訂閱將被取消。