Active Directory Script Highlight: Group Policy Object Cleanup and Efficiency

Going a step further from the previous post with a little more detail, the script below adds of GPOStatus, and version increment number for Computer and Users section for each Group Policy.

Get-GPO -All | Sort GPOStatus | Format-Table Displayname, GPOStatus, CreationTime, ModificationTime,@{Label=”ComputerVersion”;Expression={$_.computer.dsversion}},@{Label=”UserVersion”;Expression={$_.user.dsversion}}

image

 

 

 

 

 

 

With the addition of GPOStatus, Computer Version, and User Version, a few more cleanup options are possible, both to remove orphaned policies and to make Group Policy processing faster during logon or computer restart.

Two things to look for with the addition of GPOStatus and Computer and User Version numbers.  If you see a Group Policy with a zero in both the User version and the Computer version, you know that no settings are set for that policy and the policy can be deleted.

image

 

 

Additionally, if you see a Group Policy that has a zero in either of the User version or the Computer version and the GPOStatus is  set to AllSettingEnabled, you could speed up the Group Policy processing by disabling the User or Computer portions of the policy.

image

 

 

 

Any PowerShell tricks to keep your Group Policy Objects cleaned up.  Drop you tips in the Comments below.

This entry was posted in Active Directory, Group Policy, PowerShell and tagged , , , , , , , , , . Bookmark the permalink.

3 Responses to Active Directory Script Highlight: Group Policy Object Cleanup and Efficiency

  1. Great script!

    Format-table is great for displaying info in the console but if you want to put it into Excel to share with a team or use later I changed some things.

    Replaced Format-Table with Select
    Appended – | Export-Csv C:\PickYourLocationHere\GPO_Audit.csv -Encoding ASCII –NoTypeInformation

    This allows for a nicely formatted Excel version of this.

    Thanks again!

  2. Pingback: Active Directory Script Highlight: Simple HTML Export of all Group Policy Object Details | VirtuallyAware

Leave a comment