Contact Info

Crumbtrail » Administration » Powershell » Powershell 1.0 » Set-Tracesource

Set-Tracesource - Powershell 1.0 CmdLet

Microsoft Windows PowerShell is a command-line shell and scripting tool based on the Microsoft .NET Framework. It is designed for system administrators, engineers and developers to control and automate the administration of Windows and applications.

More than hundred command-line tools (so called "cmdlets") can be used to perform system administration tasks and Windows Management Instrumentation (WMI). These cmdlets are easy to use, with standard naming conventions and common parameters, and standard tools for piping, sorting, filtering, and formatting data and objects.


Trace a PowerShell component


-name string[]
       Name of the trace source of each component to be traced.
       Wildcards are permitted.

   -option PSTraceSourceOptions
       Type of events to trace, comma separated enclosed in quotes: 

   -filePath string
       Send the trace output to specified file. This will also select the
       file trace listener. Use -RemoveFileListener to stop this trace.

       Send the trace output to the debugger (or in Visual Studio) This will
       also select the default trace listener.

       Send the trace output to the PowerShell host.
       This will also select the PSHost trace listener.
   -listenerOption TraceOptions
       Add optional data to the prefix of each trace message in the output:
            ProcessId,ThreadId, or Callstack"

       Pass the object created by this cmdlet through the pipeline.

   -removeListener string[]
       Stop the trace by removing the trace listener. 
       Either "Host" to remove PSHost (console)
       or "Debug" to remove Debugger
       or "*" to remove all trace listeners.

   -removeFileListener string[]
       Stop the trace by removing the file trace listener associated with the
       specified trace output filename.

       Override restrictions that prevent the command from succeeding, apart
       from security settings. e.g. rename an existing file.

       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutVariable.

Start tracing for the ParameterBinding component:

PS C:\>Set-TraceSource -Name Parameterbinding -Option ExecutionFlow -PSHost '
-ListenerOption "ProcessID,TimeStamp"

Stop the trace of the ParameterBinding component:

PS C:\>set-tracesource -name ParameterBinding -RemoveListener Host