PowerShell script to check if a specified security group is added into security filtering of any GPO?
$GroupName = "YourSecurityGroupName"
$GPOs = Get-GPO -All
$GPOsWithGroup = @()
foreach ($GPO in $GPOs) {
$SecurityFilter = Get-GPPermissions -Guid $GPO.Id -All
$GroupFilter = $SecurityFilter | Where-Object { $_.Trustee.Name -eq $GroupName }
if ($GroupFilter) {
$GPOsWithGroup += $GPO.DisplayName
}
}
if ($GPOsWithGroup.Count -gt 0) {
Write-Host "The security group '$GroupName' is added in the security filtering of the following GPOs:" -ForegroundColor Green
$GPOsWithGroup
} else {
Write-Host "The security group '$GroupName' is not added in the security filtering of any GPO." -ForegroundColor Red
}
Comments
Post a Comment