MacOS:在 VSCODE ISE 中调试 Powershell 脚本管理员权限

问题描述 投票:0回答:1

使用MacOS(M2芯片):

我有 Powershell 脚本,需要以管理员身份运行 (sudo)。

要调试脚本,我需要从 pwsh 提示符在调试模式下运行脚本 - 但我不知道如何在调试模式下运行。

就像 Python 一样,我们只需调试即可

python3 -m pdb myscript.py

或者,我在 Macbook 中尝试在 ISE 模式下使用 Powershell 扩展使用 VSCode ——但我努力寻找一种方法VSCODE

中以 Sudo/管理员权限运行我的脚本
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> 

macos powershell visual-studio-code debugging powershell-ise
1个回答
0
投票

在终端中,通过运行以下命令以调试模式启动 PowerShell:

pwsh -NoProfile -ExecutionPolicy 绕过 -Command“Set-PSDebug -Trace 1; .\ScriptName.ps1”

然后,您可以使用“Set-PsBreakpoint”cmdlet 在脚本中设置断点。

© www.soinside.com 2019 - 2024. All rights reserved.