You are here:

WindowsManagement.com > PowerShell > PowerShell 1.0 > Trace-Command
ActiveXperts Network Monitor 2019 proactively manages network servers, devices, databases and more.

Trace-Command - PowerShell 1.0

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-Command


Description
Back up your Hyper-V VMs Easy & Fast. 100% built for Hyper-V. Free for 2 VMs, forever.

Usage


Options
-name string[]
       Name of the trace source of each component to be traced.
       Wildcards are permitted.
       Use Get-TraceSource to find the trace sources on your computer.

   -expression scriptblock
       The expression to be processed during the trace.
       Enclose the expression in curly braces {}
		
   -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.

   -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"

   -inputObject psobject
       An input to the expression that is being processed during the trace.
       This can be a variable, or an object passed through the pipeline.

   -argumentList Object[]
       Parameters and parameter values for the command being traced.
       This feature is especially useful for debugging dynamic parameters.
	  
   -passThru
       Pass the object created by this cmdlet through the pipeline.

   -force
       Override restrictions that prevent the command from succeeding, apart
       from security settings. e.g. override the read-only attribute on a file.

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

Example(s)
Start a trace of the "get-process notepad" expression using the defaults: "All" for tracing and "None" for the listener option:

PS C:\>Trace-Command -name metadata,parameterbinding,cmdlet -expression {get -process notepad} -pshost

Trace the actions of the ParameterBinding operations of PowerShell while it processes a Get-Alias expression:

PS C:\>$a = "i*"
trace-command -name parameterbinding {get-alias $input} -pshost -inputobject $a

The -InputObject parameter passes the variable $a to the expression.
In effect, the command being processed during the trace is "get-alias -inputobject $a"