As I'm writing this article, I'm also writing a customization for a PowerShell course I'm teaching next week in Phoenix. This customization deals with Group Policy and PowerShell. For those of you who attend my classes may already know this, but I sit their and try to ask the questions to myself that others may ask as I present the material. I finished up my customization a few hours ago and then I realized that I did not add in how to put a comment on a GPO. This is a feature that many Group Policy Administrators may not be aware of.
This past summer I attended a presentation at TechEd on Group Policy. One organization in the crowd had over 5,000 Group Policies. In an environment like that, the comment section can be priceless. I always like to write in the comment section why I created the policy so I know its purpose next week after I've completed 50 other tasks and can't remember what I did 5 minutes ago.
In the Group Policy module for PowerShell V3, there is a New-GPO and a Get-GPO cmdlet, but there is not a Set-GPO cmdlet. Fortunately, the Get-GPO cmdlet has some "put" capabilities to it. Below I I used Get-GPO to grab one of my GPOs and I sent it to Format-List *
Notice the Description field. I did the same thing, but this time I piped it to Get-Member.
The Description field has a "set" flag on it. Next I went ahead, grabbed the object and set the description field.
When I look at the comment field in the GPO, there it is!