Powershell to search with string in all GPO
Powershell to search with string in all GPO
$string = Read-Host -Prompt "What string do you want to search for?"
$DomainName = $env:USERDNSDOMAIN
write-host "Finding all the GPOs in $DomainName"
Import-Module grouppolicy
$allGposInDomain = Get-GPO -All -Domain $DomainName
Write-Host "Starting search...."
foreach ($gpo in $allGposInDomain) {
$report = Get-GPOReport -Guid $gpo.Id -ReportType Xml
if ($report -match $string) {
$Match = write-host "********** Match found in: $($gpo.DisplayName) **********"
}
else {
$Nomatch = Write-Host "No match in: $($gpo.DisplayName)"
} }
$string = Read-Host -Prompt "What string do you want to search for?"
$DomainName = $env:USERDNSDOMAIN
write-host "Finding all the GPOs in $DomainName"
Import-Module grouppolicy
$allGposInDomain = Get-GPO -All -Domain $DomainName
Write-Host "Starting search...."
foreach ($gpo in $allGposInDomain) {
$report = Get-GPOReport -Guid $gpo.Id -ReportType Xml
if ($report -match $string) {
$Match = write-host "********** Match found in: $($gpo.DisplayName) **********"
}
else {
$Nomatch = Write-Host "No match in: $($gpo.DisplayName)"
} }
Comments
Post a Comment