且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在具有管理员权限的Windows Task Scheduler中设置Powershell脚本?

更新时间:2023-02-07 17:16:48

这最终对我有用.

Program/script: powershell
Add arguments (optional): -ExecutionPolicy Bypass -command "E:\Tableau\test.ps1 2>&1 > E:\Tableau\test_output.txt"

或通过单个命令从管理员提升的CMD运行:

Or in a single command to run from an administrator elevated CMD:

powershell -ExecutionPolicy Bypass -command "E:\Tableau\test.ps1 2>&1 > E:\Tableau\test_output.txt"

真正的问题是我正在Google Cloud VM上运行此软件,并且需要更改VM的范围才能访问所有API.

The real issue was that I was running this on a Google Cloud VM and I needed to change the scopes of the VM to have access to all the APIs.

完成此操作后,我就能够成功运行脚本.

After I did that, I was able to run the script successfully.