如何将 PowerShell 模式从受限模式更改为全语言模式? [英] how to change PowerShell mode to fulllanguage mode from constrained mode?

查看:205
本文介绍了如何将 PowerShell 模式从受限模式更改为全语言模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打开 PS 或 PSISE,它们都是我不期望的约束语言模式.

I open the PS or PSISE, they are both constrianedlanguage mode which I do not expect.

我不知道为什么是 ConstrainedLanguage.两天前,只是 PSISE 处于受约束模式,而 PS 处于全语言模式.现在在我重新启动计算机后,它们都是受约束的模式,这让我很困扰,因为我真的需要使用完整模式..

I don't know why it's ConstrainedLanguage. Two days ago it's just the PSISE is in constrainedmode and the PS is fulllanguage mode. Now after I restart my computer, both of them is constrainedmode and it's so bothering me because I really need to use the full mode..

我尝试以管理员身份启动 PS,但没有成功.尝试创建一个新的环境变量 __PSLockdownPolicy 并将其设置为 1 或 0,仍然无效.

I've tried to start PS as admin, not working. Tried to create a new environment variable __PSLockdownPolicy and set it to 1 or 0, still not working.

我尝试了powershell.exe -version 2",它是完整语言,但版本 2 太低,我无法使用某些高级模块.

I tried "powershell.exe -version 2", and it's fulllanguage but the version 2 is too low that I cannot use some advanced module.

PS C:\windows\system32> $ExecutionContext.SessionState.LanguageMode
ConstrainedLanguage

PS C:\windows\system32> $ExecutionContext.SessionState.LanguageMode = 'fulllanguage'
Cannot set property. Property setting is supported only on core types in this language mode.
At line:1 char:1
+ $ExecutionContext.SessionState.LanguageMode = 'fulllanguage'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertySetterNotSupportedInConstrainedLanguage

我希望我可以在全语言模式下打开 PS.感谢您的帮助!

I expect I can open the PS in fulllanguage mode. Thanks for all your help!

推荐答案

锁定策略在 PowerShell v2 中不可用.您可以通过从管理命令提示符运行来检查您的计算机是否应用了组策略:

The lock down policy isn't available in PowerShell v2. You can check if you have a Group Policy applied to your machine by running from an administrative command prompt:

gpresult /v 

您可以搜索 PowerShell 的输出以查找可能由系统管理员应用于系统的 PowerShell 相关组策略.

You can search the output for PowerShell to find PowerShell related group policies that may be applied to the system by a system administrator.

您可以检查是否

$Env:__PSLockdownPolicy

如果已配置,则设置为 8 = 全语言模式.这可以在注册表 HKLM\System\CurrentControlSet\Control\SESSION MANAGER\Environment__PSLockdownPolicy 中配置

If configured, a setting of 8 = Full language mode. This could be configured in registry HKLM\System\CurrentControlSet\Control\SESSION MANAGER\Environment__PSLockdownPolicy

如果找不到锁定 PowerShell 的原因,请启动 ProcMon 并设置过滤器:

If you can't find what is locking down PowerShell launch ProcMon and set a filter:

  • 操作是 RegQueryValue Include
  • 进程名称为 PowerShell.exe 包含
  • 进程名称为 PowerShell_Ise.exe 包含
  • 结果是成功

然后启动 PowerShell,您可以查看加载的键,并检查详细信息列中的值设置为什么.通过这种方法,您可以识别任何锁定 PowerShell 的注册表配置.如果锁定是由组策略应用的,您可以删除密钥以暂时启用它,但一旦组策略重新应用,如果未从管理级别更改,该设置将恢复.

And launch PowerShell, you can look through the keys that are loaded, and check the details column for what the value is set to. Through this approach you can identify anything registry configuration locking down PowerShell. If the lock down is applied by group policy you can delete the key to temporarily enable it, but once group policy re-applies the setting will come back, if it is not changed from administration level.

这篇关于如何将 PowerShell 模式从受限模式更改为全语言模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆