Why are my powershell scripts not running?

Tags: powershell

I wrote a simple batch file as a powershell script, and i am getting errors when they run.

It's in a scripts directory in my path.

Cannot be loaded because the execution of scripts is disabled on this system. 
please see "get-help about-signing".

I looked in the help, but it's less than helpful.

@Matt HAmilton's answer FTW


I was able to bypass this error by invoking powershell like this:

powershell -executionpolicy bypass -File .\MYSCRIPT.ps1

That is, I added the -executionpolicy bypass to the way I invoked the script.

This worked on Windows 7 Service Pack 1. I am new to powershell, so there could be caveats to doing that that I am not aware of.

you need to run set-executionpolicy:

Set-ExecutionPolicy Restricted <-- Will not allow any powershell scripts to run.  Only individual commands may be run.

Set-ExecutionPolicy AllSigned <-- Will allow signed powershell scripts to run.

Set-ExecutionPolicy RemoteSigned <-- Allows unsigned local script and signed remote powershell scripts to run.

Set-ExecutionPolicy Unrestricted <-- Will allow unsigned powershell scripts to run.  Warns before running downloaded scripts.

Set-ExecutionPolicy Bypass <-- Nothing is blocked and there are no warnings or prompts.

Hope this helps!

By : Nadeem_MK

"Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process"

worked for me even when:

"Access to the registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' is denied."

This video can help you solving your question :)
By: admin