top of page
Search

The Magical GPO Searcher

  • ToddimusPrime
  • May 10, 2021
  • 1 min read

Does your organization have about 3 trillion GPOs? Do you need to find which GPO contains a specific setting? This PowerShell script will search through all GPOs in the domain for whatever word or string you enter, then spit back a list that'll tell you where it is.


Import-Module grouppolicy
$string = Read-Host -Prompt "Enter what to search for"
$domain = $env:USERDNSDOMAIN
 
$allGPOs = Get-GPO -All -Domain $domain 
 
Write-Host "Searching..." 
foreach ($GPO in $allGPOs)
{ 
    $report = Get-GPOReport -Guid $GPO.Id -ReportType Xml 
    if ($report -match $string)
    { 
        write-host "Found in: $($GPO.DisplayName)" -ForegroundColor Green
    }
    else
    { 
        Write-Host "Not found in: $($GPO.DisplayName)" 
    }
}

Comments


©2021 by ToddimusPrime

bottom of page