Unblock downloaded PowerShell scripts


CC 2.0 image courtesy sima dimitric on Flickr

When you download and try to run a PowerShell script (a .ps1 file extension) from the internet, you see the following security warning:

Run only scripts that you trust. While scripts from the internet can be useful, this script can potentially harm your computer. If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning message. Do you want to run {script name}?



Windows prevents downloaded internet files from being runnable as part of built-in Windows security. This impedes malicious scripts from running on your machine. This error message will even appear when your PowerShell ExecutionPolicy is set to Unrestricted. To adjust your execution policy settings, see PowerShell Execution Policy Settings.


The temporary solution to this problem is to click the Run once button each time you want to run the script. However, if you need to run this script often this warning message can be annoying. There are three permanent solutions to fix the issue.

Option 1: Bypass ExecutionPolicy

As mentioned above, an Unrestricted execution policy does not prevent the error message from appearing. To disable all warning messages permanently for any downloaded internet files, you need to use the Bypass ExecutionPolicy. However, this command unblocks every script you download, trustworthy or not.

To execute this command, open a PowerShell window with administrator privileges and run the following:

Set-ExecutionPolicy Bypass

You can also reset the ExecutionPolicy back to its default setting of Restricted using

Set-ExecutionPolicy Restricted

Option 2: Unblock-File cmdlet

Instead of changing permissions for every script in PowerShell (Option 1), you can instead unblock only the file needed. To do this, run the Unblock-File cmdlet recommended in the warning message above. To unblock the file, use the following command:

Unblock-File script_name.ps1

NOTE: You do not need elevated permissions to run this command.

Option 3: File Properties

The final option is to change the properties of the file itself. Since the file was downloaded, Windows allows you to change the file’s properties.To unblock the file:

  1. Browse to the file using Windows Explorer.
  2. Right-click the file and select Properties.
  3. On the General tab, under Security, click the Unblock checkbox.
  4. Click OK.



This article has shown you three ways of running blocked PowerShell scripts downloaded from the internet. It’s recommended you grant the least permissions possible (Option 2 or Option 3) before making sweeping changes (Option 1).

About Ken Cenerelli
I am a technical writer/programmer writer/content developer, .NET developer, Microsoft MVP, public speaker, blogger, and Microsoft Azure nerd. I blog about technology at kencenerelli.wordpress.com and am on Twitter via @KenCenerelli.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: