Tuesday, July 2, 2019

GPO PowerShell Script - Search for Group Policies with No Links

#Parse XML "<LinksTo>\<SOMPath>" looking for $null entries. Output  list.
#Can take a few minutes to run

$unlinkedGPOs = New-Object System.Collections.Generic.List[System.Object]
$GPOs = Get-GPO -All

ForEach ($gpo in $GPOs)
{
    [xml]$gpoxml = Get-GPOReport -guid $gpo.Id -ReportType xml

    if(($gpoxml).GPO.LinksTo.SOMPath -eq $null)
    {
        $unlinkedGPOs.add($gpoxml.gpo.name)
    }
}

$unlinkedGPOs | out-gridview

No comments:

Post a Comment