PowerShell script to check if a specified security group is added into security filtering of any GPO?

PowerShell script to check if a specified security group is added into security filtering of any GPO?

Automation
$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

Popular posts from this blog

Public Key Infrasturcture (PKI) interview questions.

Powerful Commands in Windows

PowerShell for Beginners: Unleashing the Power of Automation