PowerShell “cannot be loaded because the execution of scripts is disabled on this system” error

Recently after a Windows Server 2008R2 implementation I had to use the new Microsoft Command Shell  the so called “Windows PowerShell” to run a script. After installing the server I opened up notepad and wrote a simple script and as you’ll know I had to save the file with a PS1 extension so that PowerShell can execute the script. and I did save the file with the PS1 extension.

As soon as Opened PowerShell and typed the path to the PS1 file and press enter, I got an error as shown below

PowerShell

Which says “File <filepath> cannot be loaded because the execution of scripts is disabled on this system. Please see "get- help about_signing" for more details.”

If you get this error, don’t panicSmile by default PowerShell is designed like this for security reasons, The Execution Policy which is in Windows PowerShell is set to Restricted which means none of the scripts will run (even if you write with your user credentials).

In Windows PowerShell type Get-ExecutionPolicy to verify

ExecPolicy

In order to be able to run scripts using Windows PowerShell type Set-ExecutionPolicy RemoteSigned

RemoteSigned

This would enable to run script using PowerShell on your computer

Advertisements

2 thoughts on “PowerShell “cannot be loaded because the execution of scripts is disabled on this system” error

  1. For an enterprise environment, use Group Policy to configure and enforce your script execution policy. I recommend at least a minimum of RemoteSigned.. Oh, and running Set-ExecutionPolicy requires an elevated session.

Leave a Reply

Fill in your details below or click an icon to log in:

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 )

Google+ photo

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

Connecting to %s