Invoke-PefCustomAction

Invoke-PefCustomAction

Creates a PEF action that runs a script block.

構文

Parameter Set: Default
Invoke-PefCustomAction [-Script] <ScriptBlock> [-InformationAction <System.Management.Automation.ActionPreference> {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend} ] [-InformationVariable <System.String> ] [-Trigger <Trigger[]> ] [ <CommonParameters>]

詳細説明

The Invoke-PefCustomAction cmdlet creates a Protocol Engineering Framework (PEF) action that runs a Microsoft PowerShell script block. Specify a script block to run and a trigger for the action.

パラメーター

-InformationAction<System.Management.Automation.ActionPreference>

Specifies how this cmdlet responds to an information event. このパラメーターに対して使用できる値:

-- SilentlyContinue
-- Stop
-- Continue
-- Inquire
-- Ignore
-- Suspend

エイリアス

infa

必須?

false

位置は?

named

既定値

none

パイプライン入力を許可する

false

ワイルドカード文字を許可する

false

-InformationVariable<System.String>

Specifies a variable in which to store an information event message.

エイリアス

iv

必須?

false

位置は?

named

既定値

none

パイプライン入力を許可する

false

ワイルドカード文字を許可する

false

-Script<ScriptBlock>

Specifies a script block to invoke. For more information about script blocks, type Get-Help about_script_blocks.

エイリアス

none

必須?

true

位置は?

1

既定値

none

パイプライン入力を許可する

false

ワイルドカード文字を許可する

false

-Trigger<Trigger[]>

Specifies an array of Trigger objects. When one of these triggers runs, the action runs the script block specified by the Script parameter.

エイリアス

none

必須?

false

位置は?

named

既定値

none

パイプライン入力を許可する

false

ワイルドカード文字を許可する

false

<CommonParameters>

このコマンドレットは次の共通パラメーターをサポートします。-Verbose、-Debug、-ErrorAction、-ErrorVariable、-OutBuffer、-OutVariable.詳細については、以下を参照してください。 about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216)。

入力

入力型は、コマンドレットにパイプできるオブジェクトの型です。

出力

出力型は、コマンドレットによって生成されるオブジェクトの型です。

Example 1: Create an ICMP trigger actionn

This command creates a script block, stored in the variable $Sb, that Invoke-PefCustomAction runs when the trigger criteria matches. The New-PefMessageTrigger cmdlet defines the trigger by specifying a filter for ICMP. When the trigger matches, the script block runs, which displays the message ICMP found.

PS C:\>  $T = New-PefKeyDownTrigger -CtrlC
PS C:\> $Sb = { $Host.UI.WriteErrorLine("ICMP found") }
PS C:\> $S = New-PefTraceSession -Mode Linear -SaveOnStop -Path "C:\Traces\Simple" -Force -SaveAsParsed
PS C:\> Add-PefMessageSource -PEFSession $S -Source Microsoft-Pef-WFP-MessageProvider
PS C:\> $T2 = New-PefMessageTrigger  -PEFSession $S -Filter "ICMP" -Repeat
PS C:\> Invoke-PefCustomAction -Script $Sb -Trigger $T2
PS C:\> Stop-PefTraceSession -PEFSession $S -Trigger $T
PS C:\> Start-PefTraceSession -PEFSession $S 

関連トピック

New-PefDateTimeTrigger

New-PefKeyDownTrigger

New-PefMessageTrigger

New-PefProcessTrigger

New-PefTimeSpanTrigger