Get Tracesource - PowerShell


The Get-TraceSource cmdlet retrieves trace sources registered in the current PowerShell session. Trace sources are used for tracing and debugging, and provide a way to track the execution of PowerShell scripts and commands.


Get-TraceSource [-Name] <string[]> [-CommandType <string[]>] [-Module <string[]>] [-IncludeInactive] [[-PSJob] <JobObject>] [-UseServerSwitches] [-Format <string>] [-OutFile <string>] [-OutVariable <string>]


  • -Name <string[]>: Specifies the names of trace sources to retrieve. Supports wildcards.
  • -CommandType <string[]>: Filters trace sources by the command types they trace.
  • -Module <string[]>: Filters trace sources by the modules they belong to. Supports wildcards.
  • -IncludeInactive: Includes inactive trace sources in the results.
  • [-PSJob] <JobObject>: Runs the command in the specified background job.
  • -UseServerSwitches: Sends the switches to the remote server when connecting remotely.
  • **-Format **: Specifies the output format. Valid values include: Table, List, and Detailed`.
  • -OutFile `: Sends the command output to the specified file.
  • -OutVariable `: Stores the command output in the specified variable.


Simple Example


This command retrieves all registered trace sources in the current session.

Filter by Name

Get-TraceSource -Name Microsoft.PowerShell

This command retrieves trace sources whose names contain “Microsoft.PowerShell”.

Filter by CommandType

Get-TraceSource -CommandType Cmdlet

This command retrieves trace sources that trace cmdlet executions.

Common Issues

  • Trace sources are not found: Ensure that the trace sources have been registered in the current session.
  • Inactive trace sources are not retrieved: Use the -IncludeInactive switch to include inactive trace sources in the results.


Get-TraceSource can be used in conjunction with other PowerShell commands or tools for advanced debugging and analysis. For example, it can be combined with the Trace-Command cmdlet to enable tracing for specific commands or scripts.