PowerShell 禁止執行指令碼
執行指令碼報錯資訊
PS E:\runajian\filebeat-6.4.3-windows-x86_64> .\install-service-filebeat.ps1
無法載入檔案 E:\runajian\filebeat-6.4.3-windows-x86_64\install-service-filebeat.ps1,因為在此係統中禁止執行指令碼。有關詳
細資訊,請參閱 "get-help about_signing"。
所在位置 行:1 字元: 32
- .\install-service-filebeat.ps1 <<<<
- CategoryInfo : NotSpecified: (:) [], PSSecurityException
- FullyQualifiedErrorId : RuntimeException
PS E:\runajian\filebeat-6.4.3-windows-x86_64> .\install-service-filebeat.ps1
無法載入檔案 E:\runajian\filebeat-6.4.3-windows-x86_64\install-service-filebeat.ps1,因為在此係統中禁止執行指令碼。有關詳
細資訊,請參閱 "get-help about_signing"。
所在位置 行:1 字元: 32
- .\install-service-filebeat.ps1 <<<<
- CategoryInfo : NotSpecified: (:) [], PSSecurityException
- FullyQualifiedErrorId : RuntimeException
題
about_signing
簡短說明
說明如何對指令碼進行簽名以使其符合 Windows PowerShell 執行策略。
詳細說明
Restricted 執行策略不允許任何指令碼執行。
AllSigned 和 RemoteSigned 執行策略可防止 Windows PowerShell 執行沒有數字簽名的指令碼。
本主題說明如何執行所選未簽名指令碼(即使在執行策略為 RemoteSigned 的情況下),還說明如何對
指令碼進行簽名以便您自己使用。
有關 Windows PowerShell 執行策略的詳細資訊,請參閱 about_Execution_Policy。
允許執行簽名指令碼
-------------------------------
首次在計算機上啟動 Windows PowerShell 時,現用執行策略很可能是 Restricted(預設設定)。
Restricted 策略不允許任何指令碼執行。
若要了解計算機上的現用執行策略,請鍵入:
get-executionpolicy
若要在本地計算機上執行您編寫的未簽名指令碼和來自其他使用者的簽名指令碼,請使用以下命令將計算機上的
執行策略更改為 RemoteSigned:
set-executionpolicy remotesigned
有關詳細資訊,請參閱 Set-ExecutionPolicy。
執行“set-ExecutionPolicy RemoteSigned ”:
執行策略更改
執行策略可以防止您執行不信任的指令碼。更改執行策略可能會使您面臨 about_Execution_Policies
幫助主題中所述的安全風險。是否要更改執行策略?
[Y] 是(Y) [N] 否(N) [S] 掛起(S) [?] 幫助 (預設值為“Y”): y