茫茫網海中的冷日
         
茫茫網海中的冷日
發生過的事,不可能遺忘,只是想不起來而已!
 恭喜您是本站第 1670876 位訪客!  登入  | 註冊
主選單

Google 自訂搜尋

Goole 廣告

隨機相片
PIMG_00261.jpg

授權條款

使用者登入
使用者名稱:

密碼:


忘了密碼?

現在就註冊!

微軟帝國 : [轉貼]Powershell 檔案無法載入,因為這個系統上已停用指令碼執行。

發表者 討論內容
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15771
[轉貼]Powershell 檔案無法載入,因為這個系統上已停用指令碼執行。

Powershell 檔案無法載入,因為這個系統上已停用指令碼執行。

Posted on 2012年七月25日 by

Powershell 執行 ps1 檔時出現: 檔案無法載入,因為這個系統上已停用指令碼執行。如需詳細資訊,請參閱 “get-help about_signing"。

原因是第一次在電腦上啟動 Windows PowerShell 時,可能會實行 Restricted 執行原則 (預設值)。Restricted 原則不會允許任何指令碼執行。

若要允許執行已簽署的指令碼

在PowerShell console下執行 Set-ExecutionPolicy RemoteSigned


PS C:\> Set-ExecutionPolicy RemoteSigned

Set-ExecutionPolicy 設定詳細參考




RestrictedThis is the default execution policy upon installation. When this policy is in effect, script execution is disabled. This includes script modules, profile files and types, and format files. PowerShell itself isn’t disabled and may still be used as an interactive command interpreter. Although this is the most secure policy, it severely impacts your ability to use PowerShell for automation.
AllSignedWhen the execution policy is AllSigned, scripts can be executed but they must be Authenticode-signed before they’ll run. When running a signed script, you’ll be asked if you want to trust the signer of the script. Section 21.4 covers the details of script signing. AllSigned is still a secure policy setting, but it makes script development difficult. In an environment where scripts will be deployed rather than created, this is the best policy.
RemoteSignedRemoteSigned requires that all scripts that are downloaded from a remote location be Authenticode-signed before they can be executed. Note that this depends on whether the application doing the download marks the script as coming from a remote location. Not all applications do this. Anything downloaded by Internet Explorer 6.0 or above, Outlook, or Outlook Express will be properly marked. RemoteSigned is the minimum recommended execution policy setting. It’s the best policy setting for script development.
UnrestrictedWhen the execution policy is Unrestricted, PowerShell will run any script. It will still prompt the user when it encounters a script that has been downloaded. Unrestricted is the least secure setting. We don’t recommend that you use this setting, but it may be necessary in some developer scenarios where RemoteSigned is still too restrictive.
Bypass
(v2 only)
Nothing is blocked and there are no warnings or prompts. This execution policy is designed for configurations in which PowerShell scripts are part of a larger application that has its own security model. The Windows Diagnostics feature in Windows 7 is a good example of this type of application.
Undefined
(v2 only)
Removes the currently assigned execution policy from the current scope. This parameter won’t remove an execution policy that’s set in a Group Policy scope (User scope or Machine scope).

節錄至:chapter 21, Security, security, security, Windows PowerShell in Action, Second Edition
參考:


原文出處: Powershell 檔案無法載入,因為這個系統上已停用指令碼執行。 | Taien's blog
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15771
[轉貼]VMware vSphere PowerCLI 檔案無法載入,因為這個系統上已停用指令碼執行。如需詳細資訊,請參閱”get-help about_signi” 的固定網址

VMware vSphere PowerCLI 檔案無法載入,因為這個系統上已停用指令碼執行。如需詳細資訊,請參閱”get-help about_signi”

由 Derek 發表於 四月 15, 2013 /

錯誤訊息 :

在開啟VMware vSphere PowerCLI 時出現以下報錯

檔案無法載入,因為這個系統上已停用指令碼執行。如需詳細資訊,請參閱”get-help about_signi”

 

可依照它所給的提示,使用此命令「get-help about_signing」來查看說明

然後會看到紅框內的修改指令,稍後會使用到


 

執行 「get-executionpolicy」此命令來查看執行原則,會發現顯示為「Restricted」,則是受限所以不能載入任何檔案和使用指令。

 

修改執行原則

輸入 :「set-executionpolicy remotesigned

然後選 「Y


 

接下來就關掉 VMware vSphere PowerCLI,再開啟就會正常了

 

參考文章 : http://hi.baidu.com/495216123/item/4d836ed7c89cc6cd1b72b426

  


原文出處:VMware vSphere PowerCLI 檔案無法載入,因為這個系統上已停用指令碼執行。如需詳細資訊,請參閱”get-help about_signi” | FAQ Book
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15771
[轉貼][PowerShell] cannot be loaded because the execution of scripts is disabled on this system - Server 2008 R2

[PowerShell] cannot be loaded because the execution of scripts is disabled on this system - Server 2008 R2

最近在研究PowerShell,在執行的時候遇到了一些問題
直接打開PowerShell執行 xxx.ps1 的Script是可以正常運作的
但是要使用C# 去呼叫寫好的 xxx.ps1就會發生問題了


英文版

xxx.ps1 cannot be loaded because the execution of scripts is disabled on this system.

PowerShell有些執行上的政策去限制了檔案(.ps1)的執行

有四種執行的政策

Restricted - 限制 任何的 .ps1的執行 ....這是預設值

AllSigned - 要執行的.ps1都要經過信任者的簽名發行

Remote Signed - 這是允許存取本機電腦上.ps1,但是透過網路去存取的就不行

Un Restricted - 完全不限制.ps1的執行
更多資訊

如果是自己寫的.ps1應該是 RemoteSigned 的權限就可以執行了

如畫面顯示我的執行政策已經是 UnRestricted 但是還是出現一樣的錯誤

後來才發現我使用的作業系統是 Server 2008 R2
同時會存在著 X86 和 X64兩種版本
需要檢查兩個版本是否都是可以執行的權限

X86的路徑
C:\Windows\system32\cmd.exe



X86的執行政策是 UnRestricted

接下來檢查X64的設定
C:\Windows\SysWOW64\cmd.exe

就會發現X64的執行政策是  Restricted,難怪一直都不能執行!!!
只要修改X64的政策就能執行了


這個問題困擾了我一陣子,經過這一次的經驗
下次在處理Server的問題時,就會多注意到X64和X86的版本問題

從失敗中學經驗~~

參考資料:
http://stackoverflow.com/questions/4037939/powershell-execution-of-scripts-is-disabled-on-this-system


原文出處:I'm Mr.J 沒有技術的狂熱~~只希望享受分享的喜悅~~: [PowerShell] cannot be loaded because the execution of scripts is disabled on this system - Server 2008 R2
冷日
(冷日)
Webmaster
  • 註冊日: 2008/2/19
  • 來自:
  • 發表數: 15771
[轉貼]第一次執行 PowerShell @ Win 7

第一次執行 PowerShell @ Win 7

在 Win 7 環境,第一次執行 PowerShell 程式時,遇到下列運行錯誤:
Get-PowerShellRequirements.ps1 檔案無法載入,因為這個系統上已停用指令碼執行。如需詳細資訊,請參閱 "get-help about_signing"。
At line:0 char:0


運行 get-help about_signing 指令後,得知 Windows PowerShell 執行原則的預設值 Restricted,也就是在這原則下,系統是不會允許任何指令碼執行。
所以要修改它的執行原則設定值。

用下列命令將電腦的執行原則變更為 RemoteSigned:
    set-executionpolicy remotesigned


不過,沒想到執行 set-executionpolicy remotesigned 指令後,又遇到另外一個錯誤訊息:
    Set-ExecutionPolicy : 拒絕存取登錄機碼 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell'。
    位於 行:1 字元:20
    + set-executionpolicy <<<<  remotesigned

        + CategoryInfo          : NotSpecified: (:) [Set-ExecutionPolicy], UnauthorizedAccessException
        + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.SetExecutionPolicyCommand


原來是電腦的註冊機碼,無法正常被修正;這時只好已手工方式來調整。
開始/執行/RegEdit,在 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell] 處,新增一個機碼 ExecutionPolicy,機碼值為 RemoteSigned。

你也可以把下列指令,寫成 ps1-RemoteSigned.reg 檔案 (文字檔格式),再執行之,以便直接匯入機碼值。

ps1-RemoteSigned.reg

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell]

"Path"="C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
"ExecutionPolicy"="RemoteSigned"

 

因為 set-executionpolicy 有多種設定選項:Restricted、AllSigned、RemoteSigned、Unrestricted,
為了日後使用上的方便,可以先行建制好相關的註冊檔,如:
ps1-Restricted.reg、ps1-AllSigned.reg、ps1-RemoteSigned.reg、ps1-Unrestricted.reg
只要將註冊檔中的機碼值,改成和註冊檔名一樣的文字即可。
例如:ps1-Restricted.reg 它的機碼值,就是 Restricted。

ps1- Restricted.reg

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell]
"Path"="C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
"ExecutionPolicy"=" Restricted"



原文出處:Perton 網誌: 第一次執行 PowerShell @ Win 7
前一個主題 | 下一個主題 | 頁首 | | |



Powered by XOOPS 2.0 © 2001-2008 The XOOPS Project|