Public/Search-GPOForString.ps1

<#
   .SYNOPSIS
   Search all GPOs for the specified string value
 
   .DESCRIPTION
   Search all GPOs for the specified string value
#>
    
function Search-GPOForString {
   param (
      [Parameter(Mandatory = $TRUE)][String]$SearchFor
   )

   Import-Module GroupPolicy
   
   # Set the domain to search for GPOs
   $DomainName = $env:USERDNSDOMAIN
   
   # Find all GPOs in the current domain
   Write-Host "Retrieving GPOs from domain: $DomainName"
   $allGposInDomain = Get-GPO -All -Domain $DomainName
   
   # Look through each GPO's XML for the string
   Write-Host "Starting search...."
   foreach ($gpo in $allGposInDomain) {
      $report = Get-GPOReport -Guid $gpo.Id -ReportType Xml
      if ($report -match $SearchFor) {
         Write-Host "Match found in: $($gpo.DisplayName)" -ForegroundColor Green
      } # end if
      else {
         Write-Host "No match in: $($gpo.DisplayName)" -ForegroundColor Yellow
      } # end else
   } # end foreach
} #END function