Find linked GPO's without a GPO behind them

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
LVL 18
Alex GreenProject Systems EngineerAsked:
Who is Participating?

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

x
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 https://www.windowspro.de/script/gpos-analysieren-powershell-nicht-verlinkte-leere-objekte-wmi-filter
Sorry, its in German.
0
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.
0
Michael PfisterCommented:
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
0

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
Powershell

From novice to tech pro — start learning today.