pondělí 3. listopadu 2014

PowerShell error - script is not digitally signed

Mám MS Windows Server 2012 R2 a PowerShell 4.

A zde jsem se setkal se zajímavým problémem.
Potřeboval jsem dávkově spustit PowerShell script z CMD příkazové řádky.


K tomuto jsem si vytvořil následující dávku:

powershell.exe -Command "& {d:\PowerShell\Hyper-V.ps1}"

A OUHA, po spuštění jsem obdržel následující chybku.

d:\PowerShell\Hyper-V.ps1 : File D:\PowerShell\Hyper-V.ps1 cannot be loaded. The file D:\PowerShell\Hyper-V.ps1 is not digitally signed. You cannot run this script on the current system. For more information about running scripts and setting execution policy, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:4
+ & {d:\PowerShell\Hyper-V.ps1}
+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

Okamžité a rychlé řešení je toto:

  1. Spustit PowerShell
  2. Zadat následující příkaz: Set-ExecutionPolicy bypass -Scope LocalMachine
  3. Potvrdit tlačítko: YES

Více informací o Execution Policies:
http://go.microsoft.com/fwlink/?LinkID=135170

Žádné komentáře:

Okomentovat