Enable execution of Powershell scripts

If you try to run a Powershell script, your system verifies if the script is to be trusted. This because Powershell has the potential to severely break your system in case of malicious intent.

By default, a fresh windows PC will refuse to run any script from your local drives by displaying this error message:

File C:\scripts\script.ps1 cannot be loaded because running scripts is disabled on this system.

For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.

You need to disable the default restriction. A local admin can do this by typing in the following command in a Powershell window:

Set-ExecutionPolicy RemoteSigned

This will set the restriction so files from your system wil execute, but referenced files on the internet will not. This is a safe situation to be in. If you ever want to disable running Powershell scripts, you can revert this above change via this command:

Set-ExecutionPolicy Restricted

On your screen it will look like this:

Screenshot

Other possible values for Set-ExectutionPolicy are:

  • AllSigned. Requires that all scripts and configuration files are signed by a trusted publisher, including scripts written on the local computer.
  • Bypass. Nothing is blocked and there are no warnings or prompts.
  • Default. Sets the default execution policy. Restricted for Windows clients or RemoteSigned for Windows servers.
  • RemoteSigned. Requires that all scripts and configuration files downloaded from the Internet are signed by a trusted publisher.
  • Restricted. Doesn’t load configuration files or run scripts.
  • Undefined. No execution policy is set for the scope. Removes an assigned execution policy from a scope that is not set by a Group Policy. If the execution policy in all scopes is Undefined, the effective execution policy is Restricted.
  • Unrestricted. Loads all configuration files and runs all scripts. If you run an unsigned script that was downloaded from the internet, you’re prompted for permission before it runs.