A Script To Find Settings In GPOs

IT Support Forum Forums Active Directory Group Policy General Discussion A Script To Find Settings In GPOs

Viewing 0 reply threads
  • Author
    • #1217

      If you need to find a GPO that has a particular setting or text, then this is the script for you. It was written by BritV8, but I wanted to host it on my own site to ensure it’s always available.

      This PowerShell script takes an input / parameter of a bit of text, then downloads all your group policies as XML files, then searches through them all to find which policies contain the text.

      To use it, simply run up PowerShell as administrator, then run the script. It will prompt you for some text that you want to search you group policies for. Enter the search text and hit enter.

      ❗ Note: If you want to search for anything with a backslash (“\”) character, you must double up each backslash, because \ is an escape character in PowerShell. For example, to search for \\myServer\Share, you need to enter this search string: \\\\myServer\\Share.

      Here’s the script:

      <# .Synopsis Short description .DESCRIPTION Long description .EXAMPLE Example of how to use this cmdlet .EXAMPLE Another example of how to use this cmdlet #>

      # Param1 help description


      $GPOsToCheck = get-gpo -all |Sort-Object -property displayname
      Write-Host ” Checking through” $GPOsToCheck.count “GPO’s”

      $ListOFAffectedGPOs = @()
      $count = 1
      $GPOsToCheckCount = $GPOsToCheck.count
      foreach ($item in $GPOsToCheck)
      $Result = Get-GPOReport -name $item.DisplayName -ReportType XML

      if ($Result -match $StringToFind)
      $ListOFAffectedGPOs += $item.DisplayName

      Write-Host “$count of $GPOsToCheckCount”
      Write-Host “List of GPO’s that contain $StringToFind” -ForegroundColor Green


Viewing 0 reply threads
  • You must be logged in to reply to this topic.