Executing a powershell script will sometimes result in following error message:
In order to fix this issue, following command should be executed in Windows Powershell ISE to change the execution policy for successful execution of the script:
Set – ExecutionPolicy – Scope Process – ExecutionPolicy Bypass
Other Parameters for Execution policy Settings include:
- Restricted. Does not load configuration files or run scripts. Restricted is the default execution policy.
- AllSigned. Requires that all scripts and configuration files be signed by a trusted publisher, including scripts that you write on the local computer.
- RemoteSigned. Requires that all scripts and configuration files downloaded from the Internet be signed by a trusted publisher.
- Unrestricted. Loads all configuration files and runs all scripts. If you run an unsigned script that was downloaded from the Internet, you are prompted for permission before it runs.
- Bypass. Nothing is blocked and there are no warnings or prompts.
- Undefined. Removes the currently assigned execution policy from the current scope. This parameter will not remove an execution policy that is set in a Group Policy scope.
Refer this link for different parameter settings for execution policy:Execution Policy Settings