Find linked GPO's without a GPO behind them


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.

LVL 18
Alex GreenProject Systems EngineerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Michael PfisterCommented:
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
Sorry, its in German.
Alex GreenProject Systems EngineerAuthor 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.
Michael PfisterCommented:
Oh sorry, got your question wrong.

Look at  the script from here:


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


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.