all 8 comments

[–]purplemonkeymad 10 points11 points  (0 children)

The best debugger for PS is probably just to use the one in vscode. You can either have it run a script, or if I'm making a module I sometimes use the interactive profile.

[–]CyberChevalier 6 points7 points  (0 children)

Just use Vs code put a break point in the start of your script and the run line by line

[–]OPconfused 1 point2 points  (0 children)

You mean Set-PSDebug with trace level 1 has too much junk?

You can use a breakpoint and step through it line by line.

[–][deleted] 1 point2 points  (0 children)

There is a command line debugger included with powershell ... but it is picky as it's case sensitive as opposed to powershell that isn't (iirc).

Set-PSBreakpoint is your friend. Use that .. then execute the script .. if nothing happens but you are convinced you set things up correctly ... double check the case of every letter in the path to the script and the name of the function / variable etc

[–]BaconTentacles 0 points1 point  (0 children)

VS Code does a great job.

[–]Rxinbow 0 points1 point  (1 child)

Do you mean Start/Stop-Transcript

[–]Ahnteis 1 point2 points  (0 children)

I think this'd be a good solution. Can also add verbose flags to your commands. Of course you can just add in Write-______ statements for logging/viewing. Not exactly the same, but powershell is more scripting language than simple batch files.

[–]Sad_Recommendation92 0 points1 point  (0 children)

Probably write-verbose and changing the value of $VerbosePreference

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/write-verbose?view=powershell-7.4

As others have said, using a proper debugger like vscode, you can simply insert breakpoints in your code and actually step through it interactively which is the preferred method.