Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Bulk rename 450 AD Groups with Powershell

Posted on 2010-11-18
10
Medium Priority
?
4,711 Views
Last Modified: 2012-05-10
Hi,

normally I try to script for myself and see how far I get - and ask my questions when necessary. Right know I could need a little help from scratch ;-)

What I want to do:
I have a OU with nearly 1000 Groups and need to rename about 450 of them. The current naming is something like AAA-BBB-CC-XXXXX. The new groups should be named AAA-BBB_PC-XXXXX.

Is there a chance to to the renaming with powershell?

Regards
Steffen
0
Comment
Question by:SSR-IS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 10

Expert Comment

by:abhijitmdp
ID: 34163344
0
 
LVL 27

Expert Comment

by:KenMcF
ID: 34163400
Not sure what version of OS you are running. If have 2008R you could use the MS AD cmdlets if not you can use the quest cmdlets.

You could try something like this if the group names you specified are the same.

Test first in dev or seperate OU.

$groups = get-qadgroup -searchroot "OU=Groups,DC=Domain,DC=Local" | Where {$_.name -match "AAA-BBB-CC"}
foreach ($group in $groups){
$name = $group.name -replace "-CC-", "_PC-"
rename-qadobject $group -NewName $name
}
0
 

Author Comment

by:SSR-IS
ID: 34164842
Okay thanks - I´ll try this over the weekend!
0
Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

 

Author Comment

by:SSR-IS
ID: 34183063
Hello KenMcF,

your script work absolutely perfect!
Theres one thing which should be done if possiible. The Pre-Windows2000 name is not changed with this scipt. I think it doesn´t really matter, but it would be better to do this even also.

Maybe you can extend your script, if you don´t mind?

Regards
Steffen
0
 
LVL 27

Expert Comment

by:KenMcF
ID: 34183105
try this

$groups = get-qadgroup -searchroot "OU=Groups,DC=Domain,DC=Local" | Where {$_.name -match "AAA-BBB-CC"}
foreach ($group in $groups){
$name = $group.name -replace "-CC-", "_PC-"
rename-qadobject $group -NewName $name | set-qadgroup -samaccountname $name
}
0
 

Author Comment

by:SSR-IS
ID: 34183190
Thanks for you very quick reply.
There´s an error now, where Powershell states that the pipe element is not allowed to be empt.
0
 
LVL 27

Expert Comment

by:KenMcF
ID: 34183200
Have all the groups been renamed already and just the samaccountname needs changed now?
0
 

Author Comment

by:SSR-IS
ID: 34183208
Oh, I set the naming back to the starting position - which means all groups have the naming AAA-BBB-CC-XXXXX again.
0
 
LVL 27

Accepted Solution

by:
KenMcF earned 2000 total points
ID: 34183244
I just tested this in my lab and it worked. If it errors can you post a screen shot of the error?

$groups = get-qadgroup -searchroot "OU=Groups,DC=Domain,DC=Local" | Where {$_.name -match "AAA-BBB-CC"}
foreach ($group in $groups){
$name = $group.name -replace "-CC-", "_PC-"
rename-qadobject $group.name -NewName $name | set-qadgroup -samaccountname $name
}
0
 

Author Closing Comment

by:SSR-IS
ID: 34183259
I don´t know why, maybe I had a typing error, I copied your script again and now it works.

Thanks a lot, espacially for support on sunday! 500 pts to you!

Steffen
0

Featured Post

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office 365 is a subscriptions based service which includes services like Exchange Online and Skype for business Online. These services integrate with Microsoft's online version of Active Directory called Azure Active Directory.
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question