简体   繁体   English

如何从外部获取Powershell执行策略

[英]How to get Powershell execution policy externally

I need to find out the powershell (versions 4 and 5+) execution policy without using powershell itself 我需要找出powershell(版本4和5+)执行策略,而无需使用powershell本身

I tried to look into registry - HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\PowerShell 我试图调查注册表-HKEY_LOCAL_MACHINE \\ SOFTWARE \\ Microsoft \\ PowerShell

I found ExecutionPolicy value in two keys, HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\PowerShell\\1\\ShellIds\\Microsoft.PowerShell and HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\PowerShell\\1\\ShellIds\\ScriptedDiagnostics 我在两个键HKEY_LOCAL_MACHINE \\ SOFTWARE \\ Microsoft \\ PowerShell \\ 1 \\ ShellIds \\ Microsoft.PowerShell和HKEY_LOCAL_MACHINE \\ SOFTWARE \\ Microsoft \\ PowerShell \\ 1 \\ ShellIds \\ ScriptedDiagnostics中找到了ExecutionPolicy值

The first one corresponded to the policy given by executing Get-ExecutionPolicy cmdlet, but on some servers in our environment the value is missing. 第一个与执行Get-ExecutionPolicy cmdlet给出的策略相对应,但是在我们环境中的某些服务器上,该值丢失了。 Is there any other, 100% reliable, way to check the policy without using Powershell itself? 在不使用Powershell本身的情况下,还有其他100%可靠的方法可以检查策略吗?

No key would equal Undefined 没有键等于未定义

If the execution policy in all scopes is Undefined , the effective execution policy is Restricted , which is the default execution policy. 如果所有作用域中的执行策略均为Undefined ,则有效的执行策略为Restricted ,这是默认的执行策略。

x64 64位

Current User 当前用户

HKCU\Software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell : ExecutionPolicy

Local Machine 本地机器

HKLM\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell : ExecutionPolicy

x86 86

Local Machine 本地机器

HKLM\SOFTWARE\WOW6432Node\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell : ExecutionPolicy

Machine Policy 机器政策

HKLM\Software\WOW6432Node\Policies\Microsoft\Windows\PowerShell : ExecutionPolicy

User Policy 用户政策

HKCU\Software\Policies\Microsoft\Windows\PowerShell : ExecutionPolicy

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM