Hi. I have a script that executes other scripts using runspaces. In some cases, we wanted to be able to trace those other scripts (for debugging purposes) but for some reason, Set-PSDebug doesn't seem to work at all under a runspace. Take for example the following code:
After executing this code, I can see the Write-Debug messages, the Write-Host message but no trace message. Is there a Powershell variable (like DebugPreference) or flag to enable tracing within a runspace? I've been googling this issue with no results. Just in case, I'm using Powershell v2.
Thanks in advance for any help,
by poshoholic at 2013-02-27 13:48:30
I tested this using PowerShell 2 in both STA and MTA mode and PowerShell 3. On PowerShell 2, you're right, the tracing doesn't come back as you expect. On PowerShell 3 you get back the trace messages. Seems like maybe they fixed a bug in PowerShell 3.0 since it works there. Since it's working in v3 though and not in v2, I don't know what else can be done to make this work as you expect in v2.
by yesffan at 2013-02-28 07:31:53
Thanks Kirk for your help. I guess we will have to debug the hard way until we can upgrade to v3. Thanks again!