What is Orphaned GPOs??
Orphaned GPOs are objects that are deleted from GMPC console but for different reasons, their corresponding folder is not removed. So in this case the folder remains in SYSVOL folder, however there is no GPO associated to it.
How to find out these via powershell script.
This script fetch the Orphaned GPOs of your domain environment then you can just check these GUIDs in group policy for double cross whether these are linked with any of group policy or not. then please proceed for further action.
Please let us know if you guys need step by step plan for Orphaned GPOs removal
=========================================================
Just put your domain name in “yourdomainhere.local”
=========================================================
$domain = “yourdomainhere.local”
$gpoGuids = @()
$sysvolGuids = @()
$gpoGuids = Get-GPO -All -Domain $domain | Select-Object @{ n=’GUID’; e = {$_.Id.ToString()}} | Select-Object -ExpandProperty GUID
$polPath = “\\\\$domain\\SYSVOL\\$domain\\Policies”
$polFolders = Get-ChildItem $polPath -Exclude ‘PolicyDefinitions’ | Select-Object -ExpandProperty name
foreach ($folder in $polFolders)
{
$sysvolGuids += $folder -replace ‘{|}’, “”
}
Compare-Object -ReferenceObject $sysvolGuids -DifferenceObject $gpoGuids | Select-Object -ExpandProperty InputObject
=========================================================
Thank You !!
Vipan
Thank you for this , if possible please add the steps as well.