Detecting Unlinked GPOs
Unlinked GPOs are just simply policies that aren’t applied to any OU or site. These policies aren’t
$BackupPath="C:\temp\GPOBackups" Get-GPO -All | Sort-Object displayname | Where-Object { If ( $_ | Get-GPOReport -ReportType XML | Select-String -NotMatch "<LinksTo>" ) { Backup-GPO -name $_.DisplayName -path $BackupPath $_.DisplayName | Out-File $BackupPath\unlinked.txt -Append #Outputting the results to the screen $_.Displayname | Select-Object DisplayName #Uncomment this when you're ready to delete all the ones the script finds.. # $_.Displayname | remove-gpo } }