【发布时间】:2011-06-06 13:18:16
【问题描述】:
我想以普通用户身份在 Windows 7 上运行 PowerShell 脚本。每当我尝试时,我都会收到以下错误:
File C:\Users\danv\Documents\WindowsPowerShell\profile.ps1 cannot be loaded because the
execution of scripts is disabled on this system. Please see "get-help about_signing" for
more details.
At line:1 char:2
+ . <<<< 'C:\Users\danv\Documents\WindowsPowerShell\profile.ps1'
+ CategoryInfo : NotSpecified: (:) [], PSSecurityException
+ FullyQualifiedErrorId : RuntimeException
尝试通过Set-ExecutionPolicy Unrestricted 解决失败:
PS C:\Users\danv> Set-ExecutionPolicy Unrestricted
Set-ExecutionPolicy : Access to the registry key
'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell'
is denied.
At line:1 char:20
+ Set-ExecutionPolicy <<<< Unrestricted
+ CategoryInfo : NotSpecified: (:) [Set-ExecutionPolicy], UnauthorizedAccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.SetExecutionPolicyCommand
我可以以管理员身份运行Set-ExecutionPolicy Unrestricted 命令,但这似乎不会传播给非管理员用户。
如何以非管理员身份成功运行脚本?
【问题讨论】:
标签: windows-7 powershell