Condividi tramite


Invoke-PefCustomAction

Invoke-PefCustomAction

Creates a PEF action that runs a script block.

Sintassi

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

Descrizione dettagliata

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.

Parametri

-InformationAction<System.Management.Automation.ActionPreference>

Specifies how this cmdlet responds to an information event. I valori accettabili per questo parametro sono:

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

Alias

infa

Obbligatorio?

false

Posizione?

named

Valore predefinito

none

Accetta input da pipeline?

false

Accetta caratteri jolly?

false

-InformationVariable<System.String>

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

Alias

iv

Obbligatorio?

false

Posizione?

named

Valore predefinito

none

Accetta input da pipeline?

false

Accetta caratteri jolly?

false

-Script<ScriptBlock>

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

Alias

none

Obbligatorio?

true

Posizione?

1

Valore predefinito

none

Accetta input da pipeline?

false

Accetta caratteri jolly?

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.

Alias

none

Obbligatorio?

false

Posizione?

named

Valore predefinito

none

Accetta input da pipeline?

false

Accetta caratteri jolly?

false

<CommonParameters>

Questo cmdlet supporta i parametri comuni: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer e -OutVariable. Per altre informazioni, vedere   about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).

Input

Il tipo di input è il tipo degli oggetti che è possibile reindirizzare al cmdlet.

Output

Il tipo di output corrisponde al tipo di oggetti generati dal cmdlet.

Esempi

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 

Argomenti correlati

New-PefDateTimeTrigger

New-PefKeyDownTrigger

New-PefMessageTrigger

New-PefProcessTrigger

New-PefTimeSpanTrigger