Export (0) Print
Expand All

New-PefKeyDownTrigger

Windows Server 2012 R2 and Windows 8.1

Updated: September 10, 2014

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

New-PefKeyDownTrigger

Creates a trigger that signals when a user presses Ctrl+C.

Syntax

Parameter Set: Default
New-PefKeyDownTrigger [-Key <Char[]> ] [-Repeat] [ <CommonParameters>]




Detailed Description

The New-PefKeyDownTrigger cmdlet creates a trigger that signals when a user presses Ctrl+C. You can use this keystroke trigger to start or stop a Protocol Engineering Framework (PEF) Trace Session. The trigger becomes active when you associate it to a PEF action.

The Windows PowerShell® Integrated Scripting Environment (ISE) does not support this type of trigger.

Parameters

-Key<Char[]>

This parameter is not currently used. Ctrl+C is the only keystroke trigger that you can use to start or stop a PEF Trace Session.


Aliases

none

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 the keyboard input that you specify. 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.

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: Save the contents of a Trace Session with a key down trigger

This example creates a PEF Trace Session that you can save at any time by using the keyboard shortcut Ctrl+C. This example specifies the trigger explicitly; however, the use of Ctrl+C to stop the Trace Session is the default behavior.

The first command uses the New-PefTraceSession cmdlet to create a Trace Session that runs in the Circular mode, and stores a Trace Session object in the $TraceSession01 variable.

The second command uses the Add-PefMessageSource cmdlet to add the specified message trace source.

The third command uses the current cmdlet to create a trigger based on the keyboard shortcut Ctrl+C and stores it in the $Trigger01 variable.

The fourth command creates a save action for the Trace Session stored in the $TraceSession01 variable, which uses the trigger specified in the $Trigger01 variable. The command also specifies a name for the trace file to save. In addition, the command uses the Force parameter and therefore does not prompt you before replacing an existing file.

The final command uses the Start-PefTraceSession cmdlet to start the session.


PS C:\> $TraceSession01 = New-PefTraceSession -Mode Circular -SaveOnStop
PS C:\> Add-PefMessageSource -PEFSession $TraceSession01 –Source "Microsoft-PEF-NDIS-PacketCapture"
PS C:\> $Trigger01 = New-PefKeyDownTrigger -CTRLC
PS C:\> Save-PefDataCollection -PEFSession $TraceSession01 -Path "C:\Traces\Trace01.matu" -Force -Trigger $Trigger01
PS C:\> Start-PefTraceSession -PEFSession $TraceSession01

Related topics

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