Powershell: ExecutionPolicy is unable to be read/set

I was trying to run a powershell script (which I have run before) and received the following error:
Authorizationmanager Check Failed

I figured it was the Execution Policy, so ran:

Set-ExecutionPolicy Unrestricted

I then received:

Set-ExecutionPolicy : Initialization failure
At line:1 char:20
+ set-executionpolicy <<<< unrestricted
+ CategoryInfo : NotSpecified: (:) [Set-ExecutionPolicy], ManagementException
+ FullyQualifiedErrorId : System.Management.ManagementException,Microsoft.PowerShell.Commands.SetExecutionPolicyCommand

The same initialization error occurs for Get-ExecutionPolicy

Some basic commands seem to work fine, such as:

Write-Output "hi"

Can anyone suggest a fix?

Note: This is on Windows XP

Update: If I run the contents of ascript from within the powershell command prompt, it works. I only get the errors if it is run as a script. Also, Get-ExecutionPolicy and Set-ExecutionPolicy still fail from within the powershell prompt.


确保您以管理员身份运行控制台[右键单击],然后单击“以管理员身份运行”,当您运行Set-ExecutionPolicy Unrestricted


The source of the error was due to a problem with the WMI repository. I was able to repair the repository running the following command:

Note : This is for Windows XP

rundll32 wbemupgd, UpgradeRepository

Once this was run, I was successfully able to execute Get-ExecutionPolicy, and other powershell scripts again.

A couple of links that detail repairing the WMI Repository.


Another very common case (I think this only applies post-XP), is where the .ps1 file has been 'blocked' after being downloaded from an untrusted location.

Solution: open the 'Properties' of the file in Windows Explorer, and on the 'General' tab click 'Unblock', then 'Apply' or 'OK'.

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

上一篇: 无法从系统用户的powershell运行exe

下一篇: Powershell:ExecutionPolicy无法读取/设置