Problem
Recently I moved PowerShell script files to a production environment and when executing it from the command prompt, I got this error: “File cannot be loaded because the execution of scripts is disabled on this system. Please see “get-help about_signing” for more details”. In this tip we cover what needs to be done to resolve this issue.
Solution
There are situations when you are executing a PowerShell script and it will give you the below error message:
At line:1 char:19
+ c:\scripts\regSvr.ps1 <<<<
The reason for the above error is a security setting built into Windows PowerShell called “execution policy”. Execution Policy determines how (or if) PowerShell runs scripts. By default, PowerShell’s execution policy is set to Restricted
You can verify the execution policy setting by using the Get-ExecutionPolicy PowerShell command as shown below.

You can change the PowerShell script execution behavior using “Set-ExecutionPolicy”. The Set-ExecutionPolicy cmdlet enables you to determine which Windows PowerShell scripts will be allowed to run on your computer.
Windows PowerShell has four different execution policies:
- Restricted – No scripts can be run. Windows PowerShell can be used only in interactive mode.
- AllSigned – Only scripts signed by a trusted publisher can be run.
- RemoteSigned – Downloaded scripts must be signed by a trusted publisher before they can be run.
- Unrestricted – No restrictions; all scripts can be run.
To get more information on Set-ExecutionPolicy, type “Get-Help Set-ExecutionPolicy” as shown below.

To execute the Set-ExecutionPolicy command, you must have administrator permission and for Windows Vista / Windows Server 2008 and later versions you have to open the PowerShell command prompt with Run As Administrator. Otherwise you will get the below error.

You can set the execution policy as per your requirement as shown below.
get-executionpolicy
–or
set-executionpolicy remotesigned
get-executionpolicy

Next Steps
- Check your different PowerShell environments for the current execution policy that is in place.
- Set the execution policy as per your need for each system
- Review these other PowerShell tips

Biography
Jugal Shah is the founder of SQLDBPool.com, where he is writes articles on SQL Server Administration and Development. Jugal has 8+ years of extensive experience in SQL Server Database administration and development. Jugal has worked on SQL Server 2000, 2005, 2008 and 2008 R2. In his current assignment, Jugal is managing large critical databases. His expertise is in database security, performance tuning and implementing high availability solutions. He can be contacted at jugal.shah@sqldbpool.com. He has been recognized as a SQL Server MVP since 2010.
- MSSQLTips Awards: Trendsetter (25+ tips) – 2013