There are (at least) two ways to do this in PowerShell, depending upon which version of Windows you have. If you are in a Windows 7 or Server 2008-R2 world, then the Microsoft-supplied GroupPolicy module makes it easy.
Simply open PowerShell, type:
Import-Module GroupPolicyAnd then you can use the aptly named Rename-GPO cmdlet to get the job done, as so:
rename-gpo “My Security GPO” -TargetName “My Security GPO 2″Simple!
If you don’t have Win7 or Server 2008-R2, no problem. You can use our GPMC cmdlets, available at www.sdmsoftware.com/freeware, to solve it almost as easily! Specifically, the Get-SDMGPO cmdlet will let you get a reference to a GPO and from there, you can modify the DisplayName property on the GPO to change the GPO’s name, as follows:
(Get-SDMgpo “My Security GPO” -native).DisplayName = “My Security GPO2″So, this is a bit more complicated than Rename-GPO but not much–still a one-liner. It basically calls Get-SDMGPO to get a reference to the current GPO by name and uses the -native parameter so that the reference we get is a COM object. Once we do that, we can set the value of the DisplayName property to the new value and we’re done!
Now, since the title of this blog post includes the word “bulk” we should talk about how you can scale this up. There’s a couple of ways to do this across multiple GPOs at once. Probably the easiest is to create CSV file that includes the list of GPO names that you want to change and the new name for each, as such:
OldName,NewName Securitypolicy,Marketing Security Policy Desktop Lockdown,Marketing Desktop Lockdown IE Lockdown, Marketing IE Lockdown
Once you have that CSV file, you can use the Import-CSV cmdlet to bring those values into a variable in PowerShell and iterate through them to rename all GPOs. The following shows how to do this using our SDM GPMC cmdlets:
$rename = import-csv .gporename.csv foreach ($item in $rename){(Get-SDMgpo $item.OldName -native).DisplayName = $item.NewName}After importing the CSV list into a variable called $rename, we use the foreach cmdlet to iterate through each line of the CSV and pass that to our rename command that we used above, simply replacing old and new GPO names with the properties OldName and NewName from the CSV file. Easy!
Hope this helps with your bulk renaming operations. PowerShell makes it painless!
Darren
NOV







About the Author:
Darren Mar-Elia is CTO & Founder of SDM Software, Inc. Darren has over 25 years of IT and Software experience in the Microsoft technology area, including serving as a Director in Infrastructure at Charles Schwab, CTO of Windows Management Solutions at Quest Software, and Sr. Director of Product Engineering at DesktopStandard. He has been a Microsoft MVP in Group Policy technology for the last 6 years and has written and spoken on Active Directory, Group Policy and PowerShell topics frequently over the years. He maintains the popular Group Policy resource web site at www.gpoguy.com and has been a contributing editor for Windows IT Pro Magazine since 1997. He has written and contributed to twelve books on Windows. Darren also speaks frequently at conferences on Windows infrastructure topics.