Find linked GPO's without a GPO behind them

Alex
Alex used Ask the Experts™
on
Morning,

I'm trying to figure out a powershell script that will pull all the GPO links that don't have a GPO assigned to them. I'm assuming it'll be something like get-gplink and then pipe that to a get-gpo and then filter out anything that isn't required, I have no idea where to even start so if anyone can either give me a script or tell me how i'd appreciate it.

Thanks
Alex
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Get-GPO -All | %{[XML]$GPOs = Get-GPOReport -Name $_.DisplayName -ReportType XML; $GPOs.GPO.Name + ";" + $GPOs.GPO.LinksTo.SOMName}

Open in new window


Lists all GPOs and where they link to as CSV.

Thanks to https://www.windowspro.de/script/gpos-analysieren-powershell-nicht-verlinkte-leere-objekte-wmi-filter
Sorry, its in German.
AlexSenior Infrastructure Analyst

Author

Commented:
OK but what i'm looking for are links on an OU but don't have the GPO behind it or it's been deleted, so essentially an orphaned link.
Oh sorry, got your question wrong.

Look at  the script from here: https://blogs.technet.microsoft.com/thbouche/2013/07/10/get-gplink-function-and-gplink-backup/

Download: https://gallery.technet.microsoft.com/scriptcenter/Get-GPlink-Function-V13-b31253b4

And use the following command to get all OUs and scan them for "Orphaned" links

Get-ADOrganizationalUnit -Filter * -Properties  DistinguishedName | Select-Object -Property DistinguishedName | % {Get-Gplink -path $_.DistinguishedName} | where DisplayName -like "Orphaned*" 

Open in new window

HTH

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial