New-PefProcessTrigger

New-PefProcessTrigger

Creates a trigger that signals when a process exits.

Syntax

Parameter Set: Default
New-PefProcessTrigger [-FilePath] <String> [[-Arguments] <String> ] [-InformationAction <System.Management.Automation.ActionPreference> {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend} ] [-InformationVariable <System.String> ] [-Repeat] [ <CommonParameters>]

Detailed Description

The New-PefProcessTrigger cmdlet creates a trigger that signals when a process exits. You can use this process trigger to invoke a process at the time you start a Protocol Engineering Framework (PEF) Trace Session with the Start-PefTraceSession cmdlet. The trigger executes the process when it becomes associated with a PEF action. When the process exits, the trigger signals. The trigger becomes active when you associate it to a PEF action.

Parameters

-Arguments<String>

Specifies parameters or parameter values that the cmdlet requires to invoke a process.

Aliases

none

Required?

false

Position?

2

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-FilePath<String>

Specifies the path and file name of the executable file that is to be invoked.

Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-InformationAction<System.Management.Automation.ActionPreference>

Specifies how this cmdlet responds to an information event. The acceptable values for this parameter are:

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

Aliases

infa

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-InformationVariable<System.String>

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

Aliases

iv

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Repeat

Indicates that the trigger runs on each occurrence of invoking a process. If you do not specify this parameter, the trigger runs only once.

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 (https://go.microsoft.com/fwlink/p/?LinkID=113216).

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 trigger that invokes a process

This example adds a trigger to a linear PEF Trace Session that invokes the ping.exe process when the Start-PefTraceSession cmdlet runs. The session actually starts when the ping command completes.

The first command uses the New-PefTraceSession cmdlet to create a Trace Session object and stores it in the $TraceSession01 variable.

The second command uses the Add-PefMessageSource cmdlet to add a provider for the Trace Session stored in the $TraceSession01 variable.

The third command uses the Stop-PefTraceSession cmdlet to stop the Trace Session stored in the $TraceSession01 variable ten minutes after the session starts, by using the New-PefDateTimeTrigger cmdlet.

The fourth command uses the Start-PefTraceSession cmdlet to start the Trace Session stored in the $TraceSession01 variable. The invoked process in the example is Ping.exe, which pings a location specified by the Arguments parameter. The sessions starts when the invoked process stops. Note that the 4 parameter value forces the use of IPv4; if unspecified, the default IP transport is used.

PS C:\> $TraceSession01 = New-PefTraceSession -Mode Linear -Name ".\myTrace.matu" -SaveOnStop -Path "C:\Traces\result.matu" -Force
PS C:\> Add-PefMessageSource -PEFSession $TraceSession01 -Source "Microsoft-Pef-WFP-MessageProvider"
PS C:\> Stop-PefTraceSession -PEFSession $TraceSession01 -Trigger (New-PefDateTimeTrigger ($dt=Get-Date).AddMinutes(10))
PS C:\> Start-PefTraceSession -PEFSession $TraceSession01 -Trigger (New-PefProcessTrigger -FilePath C:\Windows\system32\PING.EXE -Arguments "www.contoso.com -4")

New-PefTraceSession

Add-PefMessageSource

New-PefDateTimeTrigger

Stop-PefTraceSession

Start-PefTraceSession