MacOS: Debug Powershell script admin privilege in VSCODE ISE

88 Views Asked by At

Using MacOS (M2 Chip):

I've Powershell script which I need to run as Administrator (sudo).

To debug the script I need to run the script in Debug mode from the pwsh prompt --but I don't know how can I run in debug mode.

like for python we simply debug we

python3 -m pdb myscript.py

Alternatively I tried VSCode in my Macbook with Powershell extension in ISE Mode --But I am Struggling to find a way to run my script as Sudo/Administrator privilege in VSCODE

Existing PbiWorkbench (PbiWb) install detected, comparing versions...
Importing PbiWorkbench (PbiWb)...
Adding token to PbiWorkbench secure storage for future updates
Invoking PbiWb module...
OperationStopped: Must run as administrator
PS /Users/wilson> 

1

There are 1 best solutions below

0
AudioBubble On

In the Terminal, start the PowerShell in debug mode by running the following command:

pwsh -NoProfile -ExecutionPolicy Bypass -Command "Set-PSDebug -Trace 1; .\ScriptName.ps1"

Then, you can set breakpoints in the script using the "Set-PsBreakpoint" cmdlet.