Powershell v2 Trace Cmdlets Step 1 What The Heck Are These

My Powershell user group co-leader, Larry Weiss, recently pointed out the Trace cmdlets. I remembered reading the names of these once of twice, but, had never really looked at them. After I got a chance to stop and really look at these, I realized these were the keys to the kingdom in terms of really understanding what goes on under the hood of a Powershell command.  Before I get too excited, let me back up a step and start by getting everyone on the same page.

Just as there are debugging cmdlets in Powershell:
PS > get-help *debug* | ft -auto

Name             Category Synopsis
----             -------- --------
Set-PSDebug      Cmdlet   Turns script debugging features on and off, sets
                          the trace level, and toggles strict mode.
Write-Debug      Cmdlet   Writes a debug message to the console.
Debug-Process    Cmdlet   Debugs one or more processes running on the
                          local computer.
about_debuggers  HelpFile Describes the Windows PowerShell debugger.
there are trace cmdlets:
PS > get-help *trace* | ft -auto

Name             Category Synopsis
----             -------- --------
Get-TraceSource  Cmdlet   Gets the Windows PowerShell components that are
                          instrumented for tracing.
Set-TraceSource  Cmdlet   Configures, starts, and stops a trace of Windows
                          PowerShell components.
Trace-Command    Cmdlet   Configures and starts a trace of the specified
                          expression or command.
 Ill let you explore the help for these individually to get a better feel for what each one does on your own. The one thing I do want to point out, to help frame the context of the intended audience, comes from the NOTES section of the Trace-Command cmdlet,
The Windows PowerShell tracing cmdlets are designed to help Windows PowerShell developers, but they are available to all users. They let you monitor nearly every aspect of the functionality of the shell.
As noted above, the Trace (and really the Debug) cmdlets are for people writing scripts or cmdlets.  In other words, theyre not for your end user who just does some quick ten line directory searching, file copying, and, basic administrative task.  Now, that doesnt mean they cant benefit from knowing about these cmdlets.  But, more than likely, if you arent deeply interested in whats proverbially "under the hood" you will lose interest when you start working with these tools.

In my initial exploration of these cmdlets I discovered there is a little bit of an order to getting your head around them.  To run Trace-Command you need to know a few things (most but not all of which you get from the help)
  • To see output in the console, use -PSHost. Otherwise you will have to specify a different listener (a file...or, to infinity and beyond)
  • You need to be specific with what you put in the -Name parameter (its required with Trace-Command).  If you put -Name * it will run in a seemingly endless fashion because you are tying into virtually every TraceSource on your system.  Explore the TraceSources first with Trace-Source.
  • Run the examples in the Trace-Command help files first so you know what you should be expecting with basic traces.  (I actually do this at the end of the post for all three examples...but, only two give me results.)
  • Pay attention to the -Expression and -Command parameters.  They are different.  Treat them accordingly.  Start with -Command.
  • Similarly pay attention to -ListenerOption and -Option parameters.  Their descriptions (in the help make it pretty clear how to work with them.  
    • -Option matters more to me.  
    • -ListenerOption is more of a helpful item than anything (but key when dealing with multithreaded command, i.e., Jobs).  These show up immediate after each result set.  For example, in running example 3 from help (shown below)  I add two -ListenerOptions.  For each resulting line, two additional lines are added including ProcessID and ThreadID.  Demonstrated below, after the third help example.
Once you get things going a little, depending on your background, you will begin to see some connections between C++, .NET and the resulting actions as taken by Powershell.  The exact steps taken by commands as they execute begin to become apparent.  To get more insight into parameter binding, command/executable searching, etc, walk through the results and it tells its own story.  In a way, I think of it like Reflection in action, where Powershell is literally telling you every move if makes.  If you really want to master Powershell I see this as being the doorway to a new realm of insight and understanding.  Hopefully, others will find it as interesting as I do.

Get-Help Examples

Below are the commands, descriptions and results from the three commands in v2 help exactly as they appear (rearranged a little) with the results from my machine.  Your results may vary some.  Go play!  Be aware the coloring and markup in the console is much more interesting in the actual shell than it is here.

Example 1

Description

This command starts a trace of metadata processing, parameter binding, and cmdlet creation and destruction of the "get-process notepad" expression. It uses the Name parameter to specify the trace sources, the Expression parameter to specify the command, and the PSHost parameter to send the output to the console. Because it does not specify any tracing options or listener options, the command uses the defaults, "All" for the tracing options, and "None" for the listener options.

Command
trace-command -name metadata,parameterbinding,cmdlet -expression {get-process notepad} -pshost
Results

You will get two different results.  If notepad is running:
DEBUG: Cmdlet Information: 0 : Constructor Enter Ctor Microsoft.PowerShell.Commands.GetProcessCommand: 53299257
DEBUG: Cmdlet Information: 0 : Constructor Leave Ctor Microsoft.PowerShell.Commands.GetProcessCommand: 53299257
DEBUG: ParameterBinding Information: 0 : BIND NAMED cmd line args [Get-Process]
DEBUG: ParameterBinding Information: 0 : BIND POSITIONAL cmd line args [Get-Process]
DEBUG: ParameterBinding Information: 0 : BIND arg [notepad] to parameter [Name]
DEBUG: ParameterBinding Information: 0 : Binding collection parameter Name: argument type [String], parameter
type [System.String[]], collection type Array, element type [System.String], no coerceElementType
DEBUG: ParameterBinding Information: 0 : Creating array with element type [System.String] and 1 elements
DEBUG: ParameterBinding Information: 0 : Argument type String is not IList, treating this as scalar
DEBUG: ParameterBinding Information: 0 : Adding scalar element of type String to array position 0
DEBUG: ParameterBinding Information: 0 : Executing VALIDATION metadata:
[System.Management.Automation.ValidateNotNullOrEmptyAttribute]
DEBUG: ParameterBinding Information: 0 : BIND arg [System.String[]] to param [Name] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 : MANDATORY PARAMETER CHECK on cmdlet [Get-Process]
DEBUG: ParameterBinding Information: 0 : CALLING BeginProcessing
DEBUG: ParameterBinding Information: 0 : CALLING EndProcessing

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
114 5 1916 7404 72 0.09 8360 notepad
If notepad is not running:
DEBUG: Cmdlet Information: 0 : Constructor Enter Ctor Microsoft.PowerShell.Commands.GetProcessCommand: 59586914
DEBUG: Cmdlet Information: 0 : Constructor Leave Ctor Microsoft.PowerShell.Commands.GetProcessCommand: 59586914
DEBUG: ParameterBinding Information: 0 : BIND NAMED cmd line args [Get-Process]
DEBUG: ParameterBinding Information: 0 : BIND POSITIONAL cmd line args [Get-Process]
DEBUG: ParameterBinding Information: 0 : BIND arg [notepad] to parameter [Name]
DEBUG: ParameterBinding Information: 0 : Binding collection parameter Name: argument type [String], parameter
type [System.String[]], collection type Array, element type [System.String], no coerceElementType
DEBUG: ParameterBinding Information: 0 : Creating array with element type [System.String] and 1 elements
DEBUG: ParameterBinding Information: 0 : Argument type String is not IList, treating this as scalar
DEBUG: ParameterBinding Information: 0 : Adding scalar element of type String to array position 0
DEBUG: ParameterBinding Information: 0 : Executing VALIDATION metadata:
[System.Management.Automation.ValidateNotNullOrEmptyAttribute]
DEBUG: ParameterBinding Information: 0 : BIND arg [System.String[]] to param [Name] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 : MANDATORY PARAMETER CHECK on cmdlet [Get-Process]
DEBUG: ParameterBinding Information: 0 : CALLING BeginProcessing
DEBUG: ParameterBinding Information: 0 : BIND PIPELINE object to parameters: [Out-Default]
DEBUG: ParameterBinding Information: 0 : PIPELINE object TYPE = [System.Management.Automation.ErrorRecord]
DEBUG: ParameterBinding Information: 0 : RESTORING pipeline parameters original values
DEBUG: ParameterBinding Information: 0 : Parameter [InputObject] PIPELINE INPUT ValueFromPipeline NO COERCION
DEBUG: ParameterBinding Information: 0 : BIND arg [Cannot find a process with the name "notepad". Verify the
process name and call the cmdlet again.] to parameter [InputObject]
DEBUG: ParameterBinding Information: 0 : BIND arg [Cannot find a process with the name "notepad". Verify the
process name and call the cmdlet again.] to param [InputObject] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 : MANDATORY PARAMETER CHECK on cmdlet [Out-Default]
DEBUG: Cmdlet Information: 0 : Constructor Enter Ctor Microsoft.PowerShell.Commands.OutLineOutputCommand: 46632203
DEBUG: Cmdlet Information: 0 : Constructor Leave Ctor Microsoft.PowerShell.Commands.OutLineOutputCommand: 46632203
DEBUG: Cmdlet Information: 0 : Constructor Enter Ctor Microsoft.PowerShell.Commands.OutLineOutputCommand: 46632203
DEBUG: Cmdlet Information: 0 : Constructor Leave Ctor Microsoft.PowerShell.Commands.OutLineOutputCommand: 46632203
DEBUG: ParameterBinding Information: 0 : BIND NAMED cmd line args [Out-LineOutput]
DEBUG: ParameterBinding Information: 0 : BIND arg [Microsoft.PowerShell.Commands.Internal.Format.ConsoleLineOutput
to parameter [LineOutput]
DEBUG: ParameterBinding Information: 0 : COERCE arg to [System.Object]
DEBUG: ParameterBinding Information: 0 : Parameter and arg types the same, no coercion is needed.
DEBUG: ParameterBinding Information: 0 : BIND arg
[Microsoft.PowerShell.Commands.Internal.Format.ConsoleLineOutput] to param [LineOutput] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 : BIND POSITIONAL cmd line args [Out-LineOutput]
DEBUG: ParameterBinding Information: 0 : MANDATORY PARAMETER CHECK on cmdlet [Out-LineOutput]
DEBUG: ParameterBinding Information: 0 : CALLING BeginProcessing
DEBUG: ParameterBinding Information: 0 : BIND PIPELINE object to parameters: [Out-LineOutput]
DEBUG: ParameterBinding Information: 0 : PIPELINE object TYPE = [System.Management.Automation.ErrorRecord]
DEBUG: ParameterBinding Information: 0 : RESTORING pipeline parameters original values
DEBUG: ParameterBinding Information: 0 : Parameter [InputObject] PIPELINE INPUT ValueFromPipeline NO COERCION
DEBUG: ParameterBinding Information: 0 : BIND arg [Cannot find a process with the name "notepad". Verify the
process name and call the cmdlet again.] to parameter [InputObject]
DEBUG: ParameterBinding Information: 0 : BIND arg [Cannot find a process with the name "notepad". Verify the
process name and call the cmdlet again.] to param [InputObject] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 : MANDATORY PARAMETER CHECK on cmdlet [out-lineoutput]
DEBUG: Cmdlet Information: 0 : Constructor Enter Ctor Microsoft.PowerShell.Commands.FormatDefaultCommand: 48707690
DEBUG: Cmdlet Information: 0 : Constructor Leave Ctor Microsoft.PowerShell.Commands.FormatDefaultCommand: 48707690
DEBUG: Cmdlet Information: 0 : Constructor Enter Ctor Microsoft.PowerShell.Commands.FormatDefaultCommand: 48707690
DEBUG: Cmdlet Information: 0 : Constructor Leave Ctor Microsoft.PowerShell.Commands.FormatDefaultCommand: 48707690
DEBUG: ParameterBinding Information: 0 : BIND NAMED cmd line args [Format-Default]
DEBUG: ParameterBinding Information: 0 : BIND POSITIONAL cmd line args [Format-Default]
DEBUG: ParameterBinding Information: 0 : MANDATORY PARAMETER CHECK on cmdlet [Format-Default]
DEBUG: ParameterBinding Information: 0 : CALLING BeginProcessing
DEBUG: ParameterBinding Information: 0 : BIND PIPELINE object to parameters: [Format-Default]
DEBUG: ParameterBinding Information: 0 : PIPELINE object TYPE = [System.Management.Automation.ErrorRecord]
DEBUG: ParameterBinding Information: 0 : RESTORING pipeline parameters original values
DEBUG: ParameterBinding Information: 0 : Parameter [InputObject] PIPELINE INPUT ValueFromPipeline NO COERCION
DEBUG: ParameterBinding Information: 0 : BIND arg [Cannot find a process with the name "notepad". Verify the
process name and call the cmdlet again.] to parameter [InputObject]
DEBUG: ParameterBinding Information: 0 : BIND arg [Cannot find a process with the name "notepad". Verify the
process name and call the cmdlet again.] to param [InputObject] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 : MANDATORY PARAMETER CHECK on cmdlet [format-default]
DEBUG: Cmdlet Information: 0 : Constructor Enter Ctor Microsoft.PowerShell.Commands.SetStrictModeCommand: 66000505
DEBUG: Cmdlet Information: 0 : Constructor Leave Ctor Microsoft.PowerShell.Commands.SetStrictModeCommand: 66000505
DEBUG: Cmdlet Information: 0 : Constructor Enter Ctor Microsoft.PowerShell.Commands.SetStrictModeCommand: 66000505
DEBUG: Cmdlet Information: 0 : Constructor Leave Ctor Microsoft.PowerShell.Commands.SetStrictModeCommand: 66000505
DEBUG: ParameterBinding Information: 0 : BIND NAMED cmd line args [Set-StrictMode]
DEBUG: ParameterBinding Information: 0 : BIND arg [1] to parameter [Version]
DEBUG: ParameterBinding Information: 0 : Executing DATA GENERATION metadata:
[Microsoft.PowerShell.Commands.SetStrictModeCommand+ArgumentToVersionTransformationAttribute]
DEBUG: ParameterBinding Information: 0 : result returned from DATA GENERATION: 1.0
DEBUG: ParameterBinding Information: 0 : COERCE arg to [System.Version]
DEBUG: ParameterBinding Information: 0 : Parameter and arg types the same, no coercion is needed.
DEBUG: ParameterBinding Information: 0 : Executing VALIDATION metadata:
[Microsoft.PowerShell.Commands.SetStrictModeCommand+ValidateVersionAttribute]
DEBUG: ParameterBinding Information: 0 : BIND arg [1.0] to param [Version] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 : BIND POSITIONAL cmd line args [Set-StrictMode]
DEBUG: ParameterBinding Information: 0 : MANDATORY PARAMETER CHECK on cmdlet [Set-StrictMode]
DEBUG: ParameterBinding Information: 0 : CALLING BeginProcessing
DEBUG: ParameterBinding Information: 0 : CALLING EndProcessing
DEBUG: Cmdlet Information: 0 : Constructor Enter Ctor Microsoft.PowerShell.Commands.SetStrictModeCommand: 53307586
DEBUG: Cmdlet Information: 0 : Constructor Leave Ctor Microsoft.PowerShell.Commands.SetStrictModeCommand: 53307586
DEBUG: Cmdlet Information: 0 : Constructor Enter Ctor Microsoft.PowerShell.Commands.SetStrictModeCommand: 53307586
DEBUG: Cmdlet Information: 0 : Constructor Leave Ctor Microsoft.PowerShell.Commands.SetStrictModeCommand: 53307586
DEBUG: ParameterBinding Information: 0 : BIND NAMED cmd line args [Set-StrictMode]
DEBUG: ParameterBinding Information: 0 : BIND arg [1] to parameter [Version]
DEBUG: ParameterBinding Information: 0 : Executing DATA GENERATION metadata:
[Microsoft.PowerShell.Commands.SetStrictModeCommand+ArgumentToVersionTransformationAttribute]
DEBUG: ParameterBinding Information: 0 : result returned from DATA GENERATION: 1.0
DEBUG: ParameterBinding Information: 0 : COERCE arg to [System.Version]
DEBUG: ParameterBinding Information: 0 : Parameter and arg types the same, no coercion is needed.
DEBUG: ParameterBinding Information: 0 : Executing VALIDATION metadata:
[Microsoft.PowerShell.Commands.SetStrictModeCommand+ValidateVersionAttribute]
DEBUG: ParameterBinding Information: 0 : BIND arg [1.0] to param [Version] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 : BIND POSITIONAL cmd line args [Set-StrictMode]
DEBUG: ParameterBinding Information: 0 : MANDATORY PARAMETER CHECK on cmdlet [Set-StrictMode]
DEBUG: ParameterBinding Information: 0 : CALLING BeginProcessing
DEBUG: ParameterBinding Information: 0 : CALLING EndProcessing
DEBUG: Cmdlet Information: 0 : Constructor Enter Ctor Microsoft.PowerShell.Commands.SetStrictModeCommand: 66248532
DEBUG: Cmdlet Information: 0 : Constructor Leave Ctor Microsoft.PowerShell.Commands.SetStrictModeCommand: 66248532
DEBUG: Cmdlet Information: 0 : Constructor Enter Ctor Microsoft.PowerShell.Commands.SetStrictModeCommand: 66248532
DEBUG: Cmdlet Information: 0 : Constructor Leave Ctor Microsoft.PowerShell.Commands.SetStrictModeCommand: 66248532
DEBUG: ParameterBinding Information: 0 : BIND NAMED cmd line args [Set-StrictMode]
DEBUG: ParameterBinding Information: 0 : BIND arg [1] to parameter [Version]
DEBUG: ParameterBinding Information: 0 : Executing DATA GENERATION metadata:
[Microsoft.PowerShell.Commands.SetStrictModeCommand+ArgumentToVersionTransformationAttribute]
DEBUG: ParameterBinding Information: 0 : result returned from DATA GENERATION: 1.0
DEBUG: ParameterBinding Information: 0 : COERCE arg to [System.Version]
DEBUG: ParameterBinding Information: 0 : Parameter and arg types the same, no coercion is needed.
DEBUG: ParameterBinding Information: 0 : Executing VALIDATION metadata:
[Microsoft.PowerShell.Commands.SetStrictModeCommand+ValidateVersionAttribute]
DEBUG: ParameterBinding Information: 0 : BIND arg [1.0] to param [Version] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 : BIND POSITIONAL cmd line args [Set-StrictMode]
DEBUG: ParameterBinding Information: 0 : MANDATORY PARAMETER CHECK on cmdlet [Set-StrictMode]
DEBUG: ParameterBinding Information: 0 : CALLING BeginProcessing
DEBUG: ParameterBinding Information: 0 : CALLING EndProcessing
DEBUG: Cmdlet Information: 0 : Constructor Enter Ctor Microsoft.PowerShell.Commands.SetStrictModeCommand: 4304649
DEBUG: Cmdlet Information: 0 : Constructor Leave Ctor Microsoft.PowerShell.Commands.SetStrictModeCommand: 4304649
DEBUG: Cmdlet Information: 0 : Constructor Enter Ctor Microsoft.PowerShell.Commands.SetStrictModeCommand: 4304649
DEBUG: Cmdlet Information: 0 : Constructor Leave Ctor Microsoft.PowerShell.Commands.SetStrictModeCommand: 4304649
DEBUG: ParameterBinding Information: 0 : BIND NAMED cmd line args [Set-StrictMode]
DEBUG: ParameterBinding Information: 0 : BIND arg [1] to parameter [Version]
DEBUG: ParameterBinding Information: 0 : Executing DATA GENERATION metadata:
[Microsoft.PowerShell.Commands.SetStrictModeCommand+ArgumentToVersionTransformationAttribute]
DEBUG: ParameterBinding Information: 0 : result returned from DATA GENERATION: 1.0
DEBUG: ParameterBinding Information: 0 : COERCE arg to [System.Version]
DEBUG: ParameterBinding Information: 0 : Parameter and arg types the same, no coercion is needed.
DEBUG: ParameterBinding Information: 0 : Executing VALIDATION metadata:
[Microsoft.PowerShell.Commands.SetStrictModeCommand+ValidateVersionAttribute]
DEBUG: ParameterBinding Information: 0 : BIND arg [1.0] to param [Version] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 : BIND POSITIONAL cmd line args [Set-StrictMode]
DEBUG: ParameterBinding Information: 0 : MANDATORY PARAMETER CHECK on cmdlet [Set-StrictMode]
DEBUG: ParameterBinding Information: 0 : CALLING BeginProcessing
DEBUG: ParameterBinding Information: 0 : CALLING EndProcessing
Get-Process : Cannot find a process with the name "notepad". Verify the process name and call the cmdlet again.
At line:1 char:78
+ trace-command -name metadata,parameterbinding,cmdlet -expression {get-process <<<< notepad} -pshost + CategoryInfo : ObjectNotFound: (notepad:String) [Get-Process], ProcessCommandException + FullyQualifiedErrorId : NoProcessFoundForGivenName,Microsoft.PowerShell.Commands.GetProcessCommand
Example 2

Description

This command starts a trace of the command processor and pipeline processor while processing the "get-alias cd" command.

It uses the Name parameter to specify the trace sources, the Command parameter to specify the command, the ArgumentList parameter to specify the parameters of the Get-Alias command, the Option parameter to specify tracing options, and the ListenerOption parameter to specify the fields in the trace message prefix. The FilePath parameter sends the output to the C:TestDebug.txt file.

Command
trace-command -name commandprocessor,pipelineprocessor -command get-alias -argumentlist "ghy" -option executionflow -listenerOption "timestamp,callstack" -filepath c: estdebug.txt

# To open the output file (C: est must exist for this to work)
invoke-item C: estdebug.txt
Results 

When I run this I get nothing in the file. I tried playing around with it, but, that would not be the actual results as intended in the help.  If you get something different post what you got.  Thanks.

Example 3

Description

These commands trace the actions of the ParameterBinding operations of Windows PowerShell while it processes a Get-Alias expression that takes input from the pipeline.

In Trace-Command, the InputObject parameter passes an object to the expression that is being processed during the trace.

The first command stores the string "i*" in the $a variable. The second command uses the Trace-Command cmdlet with the ParameterBinding trace source. The PSHost parameter sends the output to the console.

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

Command
$a = "i*"
trace-command parameterbinding {get-alias $input} -pshost -inputobject $a
Results
DEBUG: ParameterBinding Information: 0 : BIND NAMED cmd line args [Get-Alias]
DEBUG: ParameterBinding Information: 0 : BIND POSITIONAL cmd line args [Get-Alias]
DEBUG: ParameterBinding Information: 0 : BIND arg [System.Array+SZArrayEnumerator] to parameter [Name]
DEBUG: ParameterBinding Information: 0 : Binding collection parameter Name: argument type [SZArrayEnumerator],
parameter type [System.String[]], collection type Array, element type [System.String], no coerceElementType
DEBUG: ParameterBinding Information: 0 : Creating array with element type [System.String] and 1 elements
DEBUG: ParameterBinding Information: 0 : Argument type SZArrayEnumerator is not IList, treating this as scalar
DEBUG: ParameterBinding Information: 0 : BIND arg [System.Array+SZArrayEnumerator] to param [Name] SKIPPED
DEBUG: ParameterBinding Information: 0 : BIND arg [System.Array+SZArrayEnumerator] to parameter [Name]
DEBUG: ParameterBinding Information: 0 : Binding collection parameter Name: argument type [SZArrayEnumerator],
parameter type [System.String[]], collection type Array, element type [System.String], no coerceElementType
DEBUG: ParameterBinding Information: 0 : Creating array with element type [System.String] and 1 elements
DEBUG: ParameterBinding Information: 0 : Argument type SZArrayEnumerator is not IList, treating this as scalar
DEBUG: ParameterBinding Information: 0 : BIND arg [System.Array+SZArrayEnumerator] to param [Name] SKIPPED
DEBUG: ParameterBinding Information: 0 : BIND arg [System.Array+SZArrayEnumerator] to parameter [Name]
DEBUG: ParameterBinding Information: 0 : COERCE arg to [System.String[]]
DEBUG: ParameterBinding Information: 0 : Trying to convert argument value from
System.Array+SZArrayEnumerator to System.String[]
DEBUG: ParameterBinding Information: 0 : ENCODING arg into collection
DEBUG: ParameterBinding Information: 0 : Binding collection parameter Name: argument type
[SZArrayEnumerator], parameter type [System.String[]], collection type Array, element type [System.String],
coerceElementType
DEBUG: ParameterBinding Information: 0 : Creating array with element type [System.String] and 1 elements
DEBUG: ParameterBinding Information: 0 : Argument type SZArrayEnumerator is not IList, treating this as
scalar
DEBUG: ParameterBinding Information: 0 : COERCE arg to [System.String]
DEBUG: ParameterBinding Information: 0 : Trying to convert argument value from
System.Array+SZArrayEnumerator to System.String
DEBUG: ParameterBinding Information: 0 : CONVERT arg type to param type using
LanguagePrimitives.ConvertTo
DEBUG: ParameterBinding Information: 0 : CONVERT SUCCESSFUL using LanguagePrimitives.ConvertTo: [i*]
DEBUG: ParameterBinding Information: 0 : Adding scalar element of type String to array position 0
DEBUG: ParameterBinding Information: 0 : BIND arg [System.String[]] to param [Name] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 : MANDATORY PARAMETER CHECK on cmdlet [Get-Alias]
DEBUG: ParameterBinding Information: 0 : CALLING BeginProcessing
DEBUG: ParameterBinding Information: 0 : CALLING EndProcessing

CommandType Name Definition
----------- ---- ----------
Alias icm Invoke-Command
Alias iex Invoke-Expression
Alias igc Invoke-GC
Alias ihy Invoke-History
Alias ii Invoke-Item
Alias ipal Import-Alias
Alias ipcsv Import-Csv
Alias ipmo Import-Module
Alias ipsn Import-PSSession
Alias ise powershell_ise.exe
Alias iwmi Invoke-WMIMethod
The modified command (as noted above) will add ProcessID and ThreadID information to each resulting line for reference.  So, if you run the same command with -ListenerOptions as shown below you effectively get three times as many lines.  I highlighted the first couple of instances of these extra lines in red to demonstrate whats different when you add -ListenerOption processid,threadid.
PS > trace-command parameterbinding {get-alias $input} -pshost -inputobject $a -ListenerOption processid,threadid
DEBUG: ParameterBinding Information: 0 : BIND NAMED cmd line args [Get-Alias]
DEBUG: ProcessId=11796
DEBUG: ThreadId=11

DEBUG: ParameterBinding Information: 0 : BIND POSITIONAL cmd line args [Get-Alias]
DEBUG: ProcessId=11796
DEBUG: ThreadId=11

DEBUG: ParameterBinding Information: 0 : BIND arg [System.Array+SZArrayEnumerator] to parameter [Name]
DEBUG: ProcessId=11796
DEBUG: ThreadId=11
DEBUG: ParameterBinding Information: 0 : Binding collection parameter Name: argument type [SZArrayEnumerator],
parameter type [System.String[]], collection type Array, element type [System.String], no coerceElementType
DEBUG: ProcessId=11796
DEBUG: ThreadId=11
DEBUG: ParameterBinding Information: 0 : Creating array with element type [System.String] and 1 elements
DEBUG: ProcessId=11796
DEBUG: ThreadId=11
DEBUG: ParameterBinding Information: 0 : Argument type SZArrayEnumerator is not IList, treating this as scalar
DEBUG: ProcessId=11796
DEBUG: ThreadId=11
DEBUG: ParameterBinding Information: 0 : BIND arg [System.Array+SZArrayEnumerator] to param [Name] SKIPPED
DEBUG: ProcessId=11796
DEBUG: ThreadId=11
DEBUG: ParameterBinding Information: 0 : BIND arg [System.Array+SZArrayEnumerator] to parameter [Name]
DEBUG: ProcessId=11796
DEBUG: ThreadId=11
DEBUG: ParameterBinding Information: 0 : Binding collection parameter Name: argument type [SZArrayEnumerator],
parameter type [System.String[]], collection type Array, element type [System.String], no coerceElementType
DEBUG: ProcessId=11796
DEBUG: ThreadId=11
DEBUG: ParameterBinding Information: 0 : Creating array with element type [System.String] and 1 elements
DEBUG: ProcessId=11796
DEBUG: ThreadId=11
DEBUG: ParameterBinding Information: 0 : Argument type SZArrayEnumerator is not IList, treating this as scalar
DEBUG: ProcessId=11796
DEBUG: ThreadId=11
DEBUG: ParameterBinding Information: 0 : BIND arg [System.Array+SZArrayEnumerator] to param [Name] SKIPPED
DEBUG: ProcessId=11796
DEBUG: ThreadId=11
DEBUG: ParameterBinding Information: 0 : BIND arg [System.Array+SZArrayEnumerator] to parameter [Name]
DEBUG: ProcessId=11796
DEBUG: ThreadId=11
DEBUG: ParameterBinding Information: 0 : COERCE arg to [System.String[]]
DEBUG: ProcessId=11796
DEBUG: ThreadId=11
DEBUG: ParameterBinding Information: 0 : Trying to convert argument value from
System.Array+SZArrayEnumerator to System.String[]
DEBUG: ProcessId=11796
DEBUG: ThreadId=11
DEBUG: ParameterBinding Information: 0 : ENCODING arg into collection
DEBUG: ProcessId=11796
DEBUG: ThreadId=11
DEBUG: ParameterBinding Information: 0 : Binding collection parameter Name: argument type
[SZArrayEnumerator], parameter type [System.String[]], collection type Array, element type [System.String],
coerceElementType
DEBUG: ProcessId=11796
DEBUG: ThreadId=11
DEBUG: ParameterBinding Information: 0 : Creating array with element type [System.String] and 1 elements
DEBUG: ProcessId=11796
DEBUG: ThreadId=11
DEBUG: ParameterBinding Information: 0 : Argument type SZArrayEnumerator is not IList, treating this as
scalar
DEBUG: ProcessId=11796
DEBUG: ThreadId=11
DEBUG: ParameterBinding Information: 0 : COERCE arg to [System.String]
DEBUG: ProcessId=11796
DEBUG: ThreadId=11
DEBUG: ParameterBinding Information: 0 : Trying to convert argument value from
System.Array+SZArrayEnumerator to System.String
DEBUG: ProcessId=11796
DEBUG: ThreadId=11
DEBUG: ParameterBinding Information: 0 : CONVERT arg type to param type using
Language

Related Posts by Categories

0 comments:

Post a Comment