win10 PowerShell 默認是禁止運行腳本的,
可以通過以下命令設置:
get-executionpolicy 查看對應配置
Restricted 執行策略不允許任何腳本運行。
AllSigned 和 RemoteSigned 執行策略可防止 WindowsPowerShell 運行沒有數字簽名的腳本。
set-ExecutionPolicy RemoteSigned 設置
PS C:\Users\12160> get-executionpolicy
Restricted
PS C:\Users\12160> set-ExecutionPolicy RemoteSigned
執行策略更改
執行策略可幫助你防止執行不信任的腳本。更改執行策略可能會產生安全風險,如 https:/go.microsoft.com/fwlink/?LinkID=135170
中的 about_Execution_Policies 幫助主題所述。是否要更改執行策略?
[Y] 是(Y) [A] 全是(A) [N] 否(N) [L] 全否(L) [S] 暫停(S) [?] 幫助 (默認值爲“N”): y
PS C:\Users\12160> get-executionpolicy
RemoteSigned
PS C:\Users\12160>