$Groups = Import-CSV -path “C:\users\Name$\Temp\Grouptest.csv”
ForEach ($Object in $Groups)
{
$OldName = $Object.OldName
$NewName = $Object.NewName
Get-ADGroup $OldName | Rename-ADObject -NewName $NewName
}
Using above command I can change group name, but not getting clue to change other attributes like SamaccontName, Proxyaddress, Emailaddress
Olaf
May 4, 2021, 7:00am
2
Admin557,
Welcome to the forums.
Could you please format your code as code here in the forum? Thanks in advance.
Most of the time when you have cmdlets with the verb “Get
” like Get-ADGroup
you also have cmdlets with the verb “Set
” like “Set-ADGroup
”.
Please read the help completely including the examples to learn how to use it.
I followed article and able to create below script, but No luck. Any suggestion.
$Groups = Import-CSV -path “C:\users\Name$\Temp\Grouptest.csv”
ForEach ($Object in $Groups)
$OldName = $Object.OldName
$SamAccountName = $Object.SamAccountName
$ProxyAddresses = $Object.ProxyAddresses
Get-ADGroup $OldName $SamAccountName $ProxyAddresses | Set-ADGroup -Replace @{SamAccountName=$newAccountName; proxyAddresses=$newProxyAddresses; mail=$newmail }
Olaf
May 4, 2021, 8:08am
4
admin557:
but No luck
“No luck ” is usually not a helpful description of what’s happening. Don’t you get errors when you run this code? If you get error messages you should post them here completely (formatted as code as well please).
admin557:
Any suggestion.
I have two.
Format your code as code.
Use curly braces around the script block of your foreach loop.
And BTW: To set the sAMAccountName you can use the parameter -SamAccountName
directly.
2 Likes