简体   繁体   English

使用 reg 键禁用/启用 powershell

[英]Disable/Enable powershell with reg key

I want to disable/enable powershell with reg key (if it is possible) to execute in cmd我想禁用/启用带有 reg 键的 powershell(如果可能)以在 cmd 中执行

For example.例如。 If I want to disable/enable WSH, simply i run in cmd with privileged:如果我想禁用/启用 WSH,只需在 cmd 中以特权运行:

:: Disable WSH
reg add "HKLM\Software\Microsoft\Windows Script Host\Settings" /v Enabled /t REG_DWORD /d 0 /f
reg add "HKCU\Software\Microsoft\Windows Script Host\Settings" /v Enabled /t REG_DWORD /d 0 /f
:: Restore WSH
reg add "HKLM\Software\Microsoft\Windows Script Host\Settings" /v Enabled /t REG_DWORD /d 1 /f
reg add "HKCU\Software\Microsoft\Windows Script Host\Settings" /v Enabled /t REG_DWORD /d 1 /f

How do I do this to disable/enable Powershell?如何禁用/启用 Powershell? (in Windows XP/7/8/8.1/10 x86 x64) (在 Windows XP/7/8/8.1/10 x86 x64 中)

Thanks谢谢

Unlike WSH there does not exist a single registry key to prevent running PowerShell.与 WSH 不同,不存在阻止运行 PowerShell 的单个注册表项。 It's significantly more complicated since PowerShell is both a scripting language and a shell.由于 PowerShell 既是脚本语言又是 shell,因此它要复杂得多。 Also Execution Policy is only for scripts.此外,执行策略仅适用于脚本。

AppLocker or Software Restriction Policies would be most of what you are looking for (if you are looking to stop the opening of powershell.exe or ISE in interactive mode) AppLocker 或软件限制策略将是您正在寻找的大部分内容(如果您希望停止以交互模式打开 powershell.exe 或 ISE)

If you wanted to disable script execution via GPO, this is the registry key that would be created on the workstation.如果您想通过 GPO 禁用脚本执行,这是将在工作站上创建的注册表项。

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\PowerShell]
"EnableScripts"=dword:00000000

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

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