Summary: Use Windows PowerShell to debug a script on a remote computer.
How can I use Windows PowerShell to debug a script on a remote computer?
Use the debugging features in the Windows PowerShell 4.0 console:
1. Use Enter-PSSession to start an interactive session on the remote computer:
PS C:\ > Enter-PSSession -ComputerName Server01
2. Debug as usual. For example, set a line breakpoint on script in the remote session:
[Server01]: PS C:\> Set-PSBreakpoint -Path C:\DebugTest1.ps1 -Line 5
3. Run the script; it stops at the breakpoint:
[Server01]: PS C:\> C:\DebugTest1.ps1
Entering debug mode. Use h or ? for help.
Hit Line breakpoint on 'C:\DebugTest1.ps1:5'
At C:\DebugTest1.ps1:5 char:1
+ $Title = "Debugging Test"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
Note The local and remote computers must be running Windows PowerShell 4.0.