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.
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
Get-PSBreakPoint | Remove-PSBreakPoint