Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>When you pass an argument into a Function without piping it in there is no unrolling of collections e.g.</p> <pre><code>function ArgShape($p) { $p.GetType().Fullname $p.Rank $p.Length $p[0].GetType().Fullname } ArgShape (Get-PSCallstack) System.Object[] 1 2 System.Management.Automation.CallStackFrame </code></pre> <p>Also, if you are expecting an array for the parameter to Pass-Callstack you can specify that like so:</p> <pre><code>function Pass-Callstack([object[]]$array) </code></pre> <p>Note that the use of the "System." namespace prefix is optional. PowerShell will prepend that if it can't find the type. Also, to specify a parameter as [object] is essentially a no-op because that is the default type. That is <code>[object]$arg0</code> is the same as <code>$arg0</code>. </p> <p>You are also passing in $null into Pass-Callstack (albeit wrapped in a single element array). The variable $psCallStack is private to the function and not visible outside it unless you do prepend it with a modifier like <code>$script:psCallStack</code>. In general I don't recommend this approach. You should output $pscallstack from Describe-Callstack like so:</p> <pre><code>function Describe-Callstack { Write-Host 'Start Describe-Callstack' $psCallStack = (Get-PSCallStack) $psCallStackType = $psCallStack.GetType() $psCallStackLength = $psCallStack.Length $psCallStackCommand0 = $psCallStack[0].command $psCallStackCommand1 = $psCallStack[1].command Write-Host $psCallStackType Write-Host $psCallStackLength Write-Host $psCallStackCommand0 Write-Host $psCallStackCommand1 $psCallStack } </code></pre> <p>Then assign the output of the function call to a variable:</p> <pre><code>$cs = Describe-Callstack </code></pre> <p>And pass that into Pass-Callstack e.g.:</p> <pre><code>Pass-Callstack $cs </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload