Set-TraceSource

Trace a PowerShell component.

Syntax
      Set-TraceSource [-name] string[] [[-option] PSTraceSourceOptions
           [-filePath string] [-debugger] [-pSHost] [-listenerOption TraceOptions]
              [-passThru] [-force] [CommonParameters]

      Set-TraceSource [-removeListener string[]] [-name] string[] 
           [CommonParameters]

      Set-TraceSource [-removeFileListener string[]] [-name] string[] 
           [CommonParameters]

Key
   -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: 
        
       "None, Constructor, Dispose, Finalizer, Method, Property, Delegates,
       Events, Exception, Lock, Error, Errors, Warning, Verbose, WriteLine,
       Data, Scope, ExecutionFlow, Assert, All".

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

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

   -pSHost 
       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:
            "None, LogicalOperationStack, DateTime, Timestamp,
            ProcessId, ThreadId, or Callstack"

   -PassThru
       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. Enter the path and filename of the 
trace output file. -Force Override restrictions that prevent the command from succeeding, apart from security settings. e.g. overwrite a read-only file. CommonParameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable, -OutBuffer -OutVariable.

The following values for PSTraceSourceOptions are combinations of other values:
ExecutionFlow: "Constructor,Dispose,Finalizer,Method,Delegates,Events,Scope"
Data: "Constructor,Dispose,Finalizer,Property,Verbose,WriteLine"
Errors: "Error,Exception"

To specify multiple PSTraceSourceOptions, separate with commas, no spaces, and enclose in quotation marks.

Examples

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

“Sweet babe, in thy face Soft desires I can trace, Secret joys and secret smiles, Little pretty infant wiles” ~ William Blake

Related:

Get-Tracesource - Get components that are instrumented for tracing.


© Copyright SS64.com 1999-2014
Some rights reserved