Why are my powershell scripts not running?

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.


Could be PowerShell's default security level, which (IIRC) will only run signed scripts.

Try typing this:

set-executionpolicy remotesigned

That will tell PowerShell to allow local (that is, on a local drive) unsigned scripts to run.

Then try executing your script again.


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!


Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process

始终使用上面的cmd来启用在当前会话中执行powershell。

链接地址: http://www.djcxy.com/p/29032.html

上一篇: 如何在PowerShell中输出一些内容

下一篇: 为什么我的powershell脚本不能运行?