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:
- Spustit PowerShell
- Zadat následující příkaz: Set-ExecutionPolicy bypass -Scope LocalMachine
- Potvrdit tlačítko: YES
Více informací o Execution Policies:
http://go.microsoft.com/fwlink/?LinkID=135170
Žádné komentáře:
Okomentovat