Last active
July 3, 2023 18:23
-
-
Save OmerMicrosoft/4eda2010c5810dc0e54225cc400211fd to your computer and use it in GitHub Desktop.
Find Group Policies with Missing Permissions
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
#Find Group Policies with Missing Permissions | |
Function Get-GPMissingPermissionsGPOs | |
{ | |
$MissingPermissionsGPOArray = New-Object System.Collections.ArrayList | |
$GPOs = Get-GPO -all | |
foreach ($GPO in $GPOs) { | |
If ($GPO.User.Enabled) { | |
$GPOPermissionForAuthUsers = Get-GPPermission -Guid $GPO.Id -All | select -ExpandProperty Trustee | ? {$_.Name -eq "Authenticated Users"} | |
$GPOPermissionForDomainComputers = Get-GPPermission -Guid $GPO.Id -All | select -ExpandProperty Trustee | ? {$_.Name -eq "Domain Computers"} | |
If (!$GPOPermissionForAuthUsers -and !$GPOPermissionForDomainComputers) { | |
$MissingPermissionsGPOArray.Add($GPO)| Out-Null | |
} | |
} | |
} | |
If ($MissingPermissionsGPOArray.Count -ne 0) { | |
Write-Warning "The following Group Policy Objects do not grant any permissions to the 'Authenticated Users' or 'Domain Computers' groups:" | |
foreach ($GPOWithMissingPermissions in $MissingPermissionsGPOArray) { | |
Write-Host "'$($GPOWithMissingPermissions.DisplayName)'" | |
} | |
} | |
Else { | |
Write-Host "All Group Policy Objects grant required permissions. No issues were found." -ForegroundColor Green | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For using in localized versions (non English) use SIDs: