{"id":4786,"date":"2023-07-10T13:07:11","date_gmt":"2023-07-10T11:07:11","guid":{"rendered":"https:\/\/leeryanrs.com\/?p=4786"},"modified":"2023-07-10T13:07:11","modified_gmt":"2023-07-10T11:07:11","slug":"search-group-policies-for-specific-setting","status":"publish","type":"post","link":"https:\/\/leeryanrs.com\/?p=4786","title":{"rendered":"Search group policies for specific setting"},"content":{"rendered":"\n<p>Sometimes you need to search in a domain environment for a specific setting in GPO&#8217;s. This script will search through all the GPO&#8217;s in the domain and list the results at the end!<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Get the string you 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 GPO's in the current domain of logged on user\nwrite-host \"Finding all the GPO's in $DomainName\"\nImport-Module grouppolicy\n$allGposInDomain = Get-GPO -All -Domain $DomainName\n&#91;string&#91;]] $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\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you need to search in a domain environment for a specific setting in GPO&#8217;s. This script will search through all the GPO&#8217;s in the domain and list the results at the end!<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15,19],"tags":[38,43,45,51],"class_list":["post-4786","post","type-post","status-publish","format-standard","hentry","category-server","category-windows","tag-powershell","tag-script","tag-server","tag-windows"],"_links":{"self":[{"href":"https:\/\/leeryanrs.com\/index.php?rest_route=\/wp\/v2\/posts\/4786","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/leeryanrs.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/leeryanrs.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/leeryanrs.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/leeryanrs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4786"}],"version-history":[{"count":0,"href":"https:\/\/leeryanrs.com\/index.php?rest_route=\/wp\/v2\/posts\/4786\/revisions"}],"wp:attachment":[{"href":"https:\/\/leeryanrs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4786"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/leeryanrs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4786"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/leeryanrs.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4786"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}