且构网

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

设置自动执行的PowerShell脚本

更新时间:2021-11-03 21:52:00

将脚本保存为.ps1文件,并使用powershell.exe启动, / p>

Save your script as a .ps1 file and launch it using powershell.exe, like this:

powershell.exe .\foo.ps1

确保指定脚本的完整路径,并确保已将执行策略级别设置为至少为RemoteSigned,以便可以运行未签名的本地脚本。

Make sure you specify the full path to the script, and make sure you have set your execution policy level to at least "RemoteSigned" so that unsigned local scripts can be run.