{"id":8542,"date":"2025-01-22T03:28:55","date_gmt":"2025-01-22T03:28:55","guid":{"rendered":"https:\/\/pariswells.com\/blog\/?p=8542"},"modified":"2025-01-22T03:28:58","modified_gmt":"2025-01-22T03:28:58","slug":"powershell-to-search-gpos-group-policies","status":"publish","type":"post","link":"https:\/\/pariswells.com\/blog\/research\/powershell-to-search-gpos-group-policies","title":{"rendered":"Powershell to Search GPOS (Group Policies )"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code class=\"\"># Get the string we want to search for \n$string = Read-Host -Prompt \"What string do you want to search for?\" \n \n# Set the domain to search for GPOs \n$DomainName = $env:USERDNSDOMAIN \n \n# Find all GPOs in the current domain \nwrite-host \"Finding all the GPOs in $DomainName\" \nImport-Module grouppolicy \n$allGposInDomain = Get-GPO -All -Domain $DomainName \n[string[]] $MatchedGPOList = @()\n\n# Look through each GPO's XML for the string \nWrite-Host \"Starting search....\" \nforeach ($gpo in $allGposInDomain) { \n    $report = Get-GPOReport -Guid $gpo.Id -ReportType Xml \n    if ($report -match $string) { \n        write-host \"********** Match found in: $($gpo.DisplayName) **********\" -foregroundcolor \"Green\"\n        $MatchedGPOList += \"$($gpo.DisplayName)\";\n    } # end if \n    else { \n        Write-Host \"No match in: $($gpo.DisplayName)\" \n    } # end else \n} # end foreach\nwrite-host \"`r`n\"\nwrite-host \"Results: **************\" -foregroundcolor \"Yellow\"\nforeach ($match in $MatchedGPOList) { \n    write-host \"Match found in: $($match)\" -foregroundcolor \"Green\"\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-8542","post","type-post","status-publish","format-standard","hentry","category-research"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/8542","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/comments?post=8542"}],"version-history":[{"count":1,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/8542\/revisions"}],"predecessor-version":[{"id":8543,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/8542\/revisions\/8543"}],"wp:attachment":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/media?parent=8542"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/categories?post=8542"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/tags?post=8542"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}