top of page

PowerShell - Get All GPO info on Domain Where applied with WMI Filter

  • Writer: Jon Boyette
    Jon Boyette
  • Jan 10, 2022
  • 1 min read

Save this as a .ps1, This when managing GPO's, will list ALL GPO's in the forest, if active, and what OU they apply to, OutPuts to c:\TEMP\GPOLinksAndWMIFilters.csv


$reportFile = "c:\TEMP\GPOLinksAndWMIFilters.csv"

Set-Content -Path $reportFile -Value ("GPO Name,# Links,Link Path,Enabled,No Override,WMI Filter")

$gpmc = New-Object -ComObject GPMgmt.GPM

$constants = $gpmc.GetConstants()

Get-GPO -All | %{

[int]$counter = 0

[xml]$report = $_.GenerateReport($constants.ReportXML)

try

{

$wmiFilterName = $report.gpo.filtername

}

catch

{

$wmiFilterName = "none"

}

$report.GPO.LinksTo | % {

if ($_.SOMPath -ne $null)

{

$counter += 1

add-Content -Path $reportFile -Value ($report.GPO.Name + "," + $report.GPO.linksto.Count + "," + $_.SOMPath + "," + $_.Enabled + "," + $_.NoOverride + "," + $wmiFilterName)

}

}

if ($counter -eq 0)

{

add-Content -Path $reportFile -Value ($report.GPO.Name + "," + $counter + "," + "NO LINKS" + "," + "NO LINKS" + "," + "NO LINKS")

}

}



 
 
 

Recent Posts

See All
PowerShell - List All Domain SPNs

Save as same List_ALL_SPNs.ps1 or similar, this LDap calls the Domain for all Service Principal names and accounts related #Build LDAP...

 
 
 
PowerShell - Start-Monitoring

This is a great script used to Monitor and Email if a server is up or down, once ran, and smtp and from address is set, then run:...

 
 
 

Comments


Post: Blog2 Post
  • Facebook
  • Twitter
  • LinkedIn

©2022 by Boyette Technical Services. Proudly created with Wix.com

bottom of page