Powershell to search with string in all GPO

Powershell to search with string in all GPO

$string = Read-Host -Prompt "What string do you want to search for?"
$DomainName = $env:USERDNSDOMAIN
write-host "Finding all the GPOs in $DomainName"
Import-Module grouppolicy
$allGposInDomain = Get-GPO -All -Domain $DomainName
Write-Host "Starting search...."
foreach ($gpo in $allGposInDomain) {
    $report = Get-GPOReport -Guid $gpo.Id -ReportType Xml
    if ($report -match $string) {
        $Match = write-host "********** Match found in: $($gpo.DisplayName) **********"
    }
    else {
        $Nomatch = Write-Host "No match in: $($gpo.DisplayName)"
    } }

Comments

Popular posts from this blog

Troubleshooting Netlogon Error Codes

Service Principal Names (SPNs) SetSPN Syntax (Setspn.exe)

Troubleshooting AD Active Directory Replication Error 8456 or 8457: "The source | destination server is currently rejecting replication requests"