Write-Debug
As long as a script is an advanced script then you can use Write-Debug.
Write-Debug -Message "Enter debug text here, variables can be included."
The script will pause at each Write-Debug and display the debug text, including any variables. This will display the current content of any variables in the debug text.
To run a script with debugging turned on you must run the script with the debug switch.
.\MyTestSwitch.ps1 -debug
Set-PSBreakpoint
Another method for debugging is to set breakpoints prior to running a script.
Set-PSBreakPoint -Script .\MyTestSwitch.ps1 -Line 5 Set-PSBreakPoint -Script .\MyTestSwitch.ps1 -Variable ComputerName
Removing PS-Breakpoints
Get-PSBreakPoint | Remove-PSBreakPoint