'Renaming localization of built-in Active Directory Groups using SID
I have a few site/domains that someone installed with a foreign language, hence the built in security groups are in localized language. It doesnt help adding a new english server because the AD is old and it preserves the names.
I have exported the groups, from both languages, and checked that I have same SIDs on the groups. We are talking about 35 groups that I want to change.
The properties I want to change is: CN, Description, Name and SamAccountName.
I have the right names in a .CSV file with these properties and the SID.
Would it be possible to use the SID to extract the right language properties from my .CSV file and change it with powershell?
I have used powershell quite a bit, but I am terrible at programming and making loops and stuff. I almost only use it line by line. Wish I could learn more about it.
I have tried using simple commands renaming the groups but I hade to use both Set-ADgroup and Rename-ADobject I think.
Is there someone who wants to help me put together a script for it, I will be most grateful?
/EDIT: link to the English version of all built in groups:
Solution 1:[1]
could do it like this, might want to add -whatif on the Rename-ADObject and Set-ADGroup or comment the commands before running it for real ;)
#Import CSV with English Group Names
$orggroups = Import-Csv -Delimiter ';' -Path "C:\Temp\default-ad-groups-
english.csv"
#Loop Through Groups
foreach ($group in $orggroups) {
$adgroup = $null
try {
#Check if we have a group with same SID
$adgroup = Get-ADGroup $group.SID
#If Name is Different, rename and update description
if ($adgroup.name -ne $group.CN) {
"change description to: " + $group.description
Set-ADGroup $adgroup -Description $group.description
"change name to: " + $group.CN
Rename-ADObject $adgroup -NewName $group.CN
}
else {
"Group " + $group.CN +" is named correctly"
}
}
catch {
#Didn't find group with same SID
"Group " + $group.CN + " does not exist"
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | SuperDOS |