If you have a lot of unused (not linked) group policy object, you can delete it with the following PowerShell script.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#Get all group policies. $GroupPolicyObjects = Get-GPO -All; #Foreach group policy found. Foreach ($GroupPolicyObject in $GroupPolicyObjects) { #If the group policy is not linked. If(Get-GPOReport $($GroupPolicyObject).DisplayName -ReportType XML | Select-String -NotMatch "<LinksTo>") { Write-Output ("INFORMATION: Deleting '" + $($GroupPolicyObject).DisplayName + "'."); #Then delete the group policy. Remove-GPO $($GroupPolicyObject).DisplayName; } } |