PowerShell for Hyper-V: Avoid Error Running PowerShell Scripts
Views (295)
This post is part of the series on PowerShell for Hyper-V.
If you try to run a PowerShell script, you will receive an error:

File C:TempResume HVVMs.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.
+ CategoryInfo : SecurityError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnauthorizedAccess
This is deliberate on Microsoft’s part to make sure a script is not inadvertently run. You can enable running of scripts, but this is very risky.
However, there is a command you can run which will, for only the script being run, allow the script to run (replace the highlighted section with your script file):
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File {your script}
The relevant section is
-ExecutionPolicy Bypass
which tells PowerShell that it may bypass the execution policy restriction.
Click to show/hide the PowerShell for Hyper-V Series Index
PowerShell for Hyper-V |
---|
Avoid Error Running PowerShell Scripts |
(Visited 1 times, 1 visits today)
This was originally posted here.
*This post is locked for comments