Export (0) Print
Expand All

Invoke-PefCustomAction

Windows Server 2012 R2 and Windows 8.1

Updated: October 17, 2013

Applies To: Windows 8.1, Windows PowerShell 4.0, Windows Server 2012 R2

Invoke-PefCustomAction

Creates a PEF action that runs a script block.

Syntax

Parameter Set: Default
Invoke-PefCustomAction [-Script] <ScriptBlock> [-Trigger <Trigger[]> ] [ <CommonParameters>]




Detailed Description

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.

Parameters

-Script<ScriptBlock>

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


Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

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.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see    about_CommonParameters.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

Outputs

The output type is the type of the objects that the cmdlet emits.

Examples

Example 1: Create a ICMP trigger action

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:\users\User1\documents\Simple" -Force -SaveAsParsed
PS C:\> Add-PefMessageProvider -Session $s -Provider Microsoft-Pef-WFP-MessageProvider
PS C:\> $t2 = New-PefMessageTrigger  -Session $s -Filter "ICMP" -Repeat
PS C:\> Invoke-PefCustomAction -Script $sb -Trigger $t2
PS C:\> Stop-PefTraceSession -Session $s -Trigger $t
PS C:\> Start-PefTraceSession -s $s 

Related topics

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft