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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章