CmdID / PowerShell / Cmdlets / Set
Set-TraceSource
Configures, starts, and stops a trace of PowerShell components. PowerShell reference
From the PowerShell reference 10 parameters
What it does
Configures, starts, and stops a trace of PowerShell components. The Set-TraceSource cmdlet configures, starts, and stops a trace of a PowerShell component. You can use it to specify which components will be traced and where the tracing output is sent.
Set-TraceSource [-Name] <String[]> [[-Option] <PSTraceSourceOptions>] [-ListenerOption <TraceOptions>] [-FilePath <String>] [-Force] [-Debugger] [-PSHost] [-PassThru] [<CommonParameters>]Set-TraceSource [-Name] <String[]> [-RemoveListener <String[]>] [<CommonParameters>]Set-TraceSource [-Name] <String[]> [-RemoveFileListener <String[]>] [<CommonParameters>]
Trace the ParameterBinding component
Set-TraceSource -Name "ParameterBinding" -Option ExecutionFlow -PSHost -ListenerOption "ProcessId,TimeStamp"IdentifyStop a trace
Set-TraceSource -Name "ParameterBinding" -RemoveListener "Host"IdentifyIts page in the reference: Set-TraceSource.
Parameters
-DebuggerIndicates that the cmdlet sends the trace output to the debugger. You can view the output in any
user-mode or kernel mode debugger or in Microsoft Visual Studio. This parameter also selects the
default trace listener.-FilePathSpecifies a file that this cmdlet sends the trace output to. This parameter also selects the file trace listener. If you use this parameter to start the trace, use the RemoveFileListener parameter to stop the trace.-ForceIndicates that the cmdlet overwrites a read-only file. Use with the FilePath parameter.-ListenerOptionSpecifies optional data to the prefix of each trace message in the output. The acceptable values for this parameter are:
- None
- LogicalOperationStack
- DateTime
- Timestamp
- ProcessId
- ThreadId
- Callstack
None is the default.
These values are defined as a flag-based enumeration. You can combine multiple values together to set multiple flags using this parameter. The values can be passed to the ListenerOption parameter as an array of values or as a comma-separated string of those values. The cmdlet will combine the values using a binary-OR operation. Passing values as an array is the simplest option and also allows you to use tab-completion on the values.-NameSpecifies which components are traced. Enter the name of the trace source of each component. Wildcards are permitted.-OptionSpecifies the type of events that are traced. The acceptable values for this parameter are:
- None
- Constructor
- Dispose
- Finalizer
- Method
- Property
- Delegates
- Events
- Exception
- Lock
- Error
- Errors
- Warning
- Verbose
- WriteLine
- Data
- Scope
- ExecutionFlow
- Assert
- All
None is the default.
The following values are combinations of other values:
- ExecutionFlow: Constructor, Dispose, Finalizer, Method, Delegates, Events, Scope
- Data: Constructor, Dispose, Finalizer, Property, Verbose, WriteLine
- Errors: Error, Exception
These values are defined as a flag-based enumeration. You can combine multiple values together to set multiple flags using this parameter. The values can be passed to the Option parameter as an array of values or as a comma-separated string of those values. The cmdlet will combine the values using a binary-OR operation. Passing values as an array is the simplest option and also allows you to use tab-completion on the values.-PassThruReturns an object representing the item with which you are working. By default, this cmdlet does not generate any output.-PSHostIndicates that this cmdlet sends the trace output to the PowerShell host. This parameter also selects the PSHost trace listener.-RemoveFileListenerStops the trace by removing the file trace listener associated with the specified file. Enter the path and file name of the trace output file.-RemoveListenerStops the trace by removing the trace listener.
Use the following values with RemoveListener:
- To remove PSHost (console), type Host.
- To remove Debugger, type Debug.
- To remove all trace listeners, type *.
To remove the file trace listener, use the RemoveFileListener parameter.