Skip to content

Commit

Permalink
Create disable_priviledged_COM.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
harishsg993010 authored Jan 17, 2023
1 parent 2ec21b3 commit 59e95b5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions disable_priviledged_COM.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Create a new software restriction policy
New-Item -Path "HKLM:\Software\Policies\Microsoft\Windows\COM" -Force | Out-Null
New-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\COM" -Name "RestrictRun" -Value 1 -PropertyType DWORD -Force | Out-Null

# Get the list of privileged COM objects
$privilegedComObjects = (Get-WmiObject -Class "Win32_COMSetting" | Where-Object {$_.Elevation -eq "privileged"}).AppID

# Disable each privileged COM object
foreach($object in $privilegedComObjects)
{
New-Item -Path "HKLM:\Software\Policies\Microsoft\Windows\COM\RestrictRun\List" -Force | Out-Null
New-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\COM\RestrictRun\List" -Name $object -Value 1 -PropertyType DWORD -Force | Out-Null
}

0 comments on commit 59e95b5

Please sign in to comment.