nex*_*xyr 1 powershell batch-file
我创建了一个 powershell 脚本并安排它每个月运行,但是当我尝试手动运行脚本时,它总是提示策略更改:
当我按回车键大约 1 小时后它仍然有提示出现
我已经将 ExecutionPolicy 设置为 Unrestricted 但我听说 Unrestricted 仍然有来自 untrsted 脚本的提示,我该如何绕过提示
或者无论如何要通过批处理文件运行 .ps1 并绕过 executionpolicy ?
谢谢
小智 6
只有三种方法可以做到这一点:
选项1:
Set-ExecutionPolicy $POLICY -Force
Run Code Online (Sandbox Code Playgroud)
Restricted- 不能运行任何脚本。Windows PowerShell 只能在交互模式下使用。
AllSigned - 只能运行由受信任发布者签名的脚本。
RemoteSigned - 下载的脚本必须由受信任的发布者签名才能运行。
Unrestricted- 没有限制; 可以运行所有 Windows PowerShell 脚本。
选项 2:
选项 3:
在 .bat 文件中运行以下内容
powershell.exe -executionpolicy bypass -windowstyle hidden -noninteractive -nologo -file "name_of_script.ps1"
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助您找到您正在寻找的答案。
| 归档时间: |
|
| 查看次数: |
14752 次 |
| 最近记录: |