When you pass an argument to a function without its pipeline, there is no collection reversal in it, for example.
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
In addition, if you expect an array for the Pass-Callstack parameter, you can indicate that this is so:
function Pass-Callstack([object[]]$array)
, "". . PowerShell , . , [object] -op, . [object]$arg0 $arg0.
$null Pass-Callstack ( ). $psCallStack , , $script:psCallStack. , . $pscallstack Describe-Callstack :
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
}
:
$cs = Describe-Callstack
Pass-Callstack, :
Pass-Callstack $cs