PowerShell Security Warning

You may get the following security warning in Powershell even though you have your execution policy set to unrestricted.  

Security warning
Run only scripts that you trust. While scripts from the internet can be useful, this script can
potentially harm your computer. Do you want to run
drive:\path\to\file\filename.ps1?
[D] Do not run [R] Run once [S] Suspend [?] Help (default is “D”):

This occurs when you are running the 64 bit version of Powershell set to unrestricted, and one of your commands calls the 32 bit version of Powershell, which is set to restricted.

Luckily there is an easy solution.  Launch the 32 bit version of Powershell and set the execution policy to match the policy you have set in the 64 bit version.

If you are on Windows 8, you can find the 32 bit x86 version of PowerShell using the Tools menu on Server Manager.

SvrMgrPSx86

Check your policy using:
Get-ExecutionPolicy

Set it to match the unrestricted policy on your 64 bit version using:
Set-ExecutionPolicy unrestricted

PSSetExecutionPolicy

 

You may  receive this error sometimes on Internet downloaded files even though both your execution policies are set to Unrestricted.  In this case, you can use Powershell 3.0 to unblock the files.  This command will unblock all files in the current directory and all subdirectories.

Get-ChildItem -Recurse | Unblock-File

 

Comments are closed.