BrianC
BrianC

Reputation: 149

Disable/Enable powershell with reg key

I want to disable/enable powershell with reg key (if it is possible) to execute in cmd

For example. If I want to disable/enable WSH, simply i run in cmd with privileged:

:: 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? (in Windows XP/7/8/8.1/10 x86 x64)

Thanks

Upvotes: 1

Views: 17747

Answers (2)

Randy Schuman
Randy Schuman

Reputation: 367

If you wanted to disable script execution via GPO, this is the registry key that would be created on the workstation.

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

Upvotes: 0

BenH
BenH

Reputation: 10054

Unlike WSH there does not exist a single registry key to prevent running PowerShell. It's significantly more complicated since PowerShell is both a scripting language and a 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)

Upvotes: 1

Related Questions