How do I obtain the stack trace of an exception thrown on a remote computer?
This question is almost identical, however the asker was satisfied with getting the SerializedRemoteInvocationInfo.PositionMessage. My situation has multiple scripts calling one another, so I need the full call stack to understand my problem.
The following snippet shows an empty stack trace:
$session = New-PSSession -ComputerName AComputer -UseSSL
$script = {C:\AScriptThatFails.ps1}
try{
Invoke-Command -Session $session -ScriptBlock $script
}
catch{
Write-Output = $_.Exception.SerializedRemoteException.StackTrace #Empty!?
}