PowerShell bug “execution of scripts is disabled on this system.”

If you are on Windows here is what you have to follow:

  1. Press the [windows] button and then type PowerShell.
  2. Run as Adiministrator
  3. Copy and Paste the following command and hit [Enter]
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
  1. Type Y and hit [Enter]
  2. Rerun the command and type A hit [Enter]
  3. Close the powershell and try again

Good luck.


The following will allow all local scripts to execute on the VM, irrespective of whether they're signed or not:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine

I am going to go out on a limb here and just rehash a portion of About Execution Policies.

The default execution policy for Windows client OSes is Restricted. This means that a script will not run automatically. If your VM has a Windows client OS and you have never changed the execution policy, then your issue is expected. If the one Windows 10 machine works without issues, then someone changed the execution policy.

On the problematic VMs, you will need to determine the scope (or account) that is running your script. Then you will need to set the execution policy accordingly.

If you are testing running a script while logged into the server as yourself, then you can just open a PowerShell console and run the following:

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

Then run the script in that same console.

The following command will list the execution policy for all scopes on that machine:

Get-ExecutionPolicy -List

You should compare the command above on the working system and the non-working system. Your issue likely be the execution policy setting for the particular scope that is running the script. If you read the link in my post, it should help you determine what you need to change specifically.

Tags:

Powershell