-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c3954d
commit 7e0cb34
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Set the Group Policy Object (GPO) name and the path to the policy setting | ||
$GpoName = "DisableCmd" | ||
$PolicyPath = "Computer Configuration\Windows Settings\Security Settings\Software Restriction Policies" | ||
|
||
# Create a new GPO | ||
New-GPO -Name $GpoName | ||
|
||
# Get the GPO | ||
$Gpo = Get-GPO -Name $GpoName | ||
|
||
# Enable the software restriction policies | ||
Set-GPRegistryValue -Name $PolicyPath -Key "Security" -ValueName "Enforcement" -Type DWord -Value 1 -GPObject $Gpo | ||
|
||
# Add the cmd.exe program to the restricted list | ||
Add-GPRegistryValue -Name $PolicyPath\Additional Rules -Key "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\cmd.exe" -ValueName "Security" -Type DWord -Value 2 -GPObject $Gpo | ||
|
||
# Link the GPO to the domain | ||
New-GPLink -Name $GpoName -Target "dc=domain,dc=com" | ||
|
||
# Force the GPO to be applied | ||
Update-GPO -Name $GpoName |