I decided to put the stuff here again as I found it is useful to extract the most important part from there
Important (for me) part of the article
Add the following code to your PowerShell profile.
function Invoke-Debugger{}
New-Alias id Invoke-Debugger
$null = Set-PSBreakPoint –Command Invoke-Debugger
Now you can set breakpoints from code itself.
Just write
function MyFunction()
{
DoSomeStuff()
Invoke-Debugger()
DoOtherStuff()
# or even simpler
id
}
You will get to the breakpoint you set and you can debug it, see callstack, fetch local variables etc…