Modify ACtive directory groups

$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

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”. :wink:

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 }

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).

I have two. :wink:

  1. Format your code as code.
  2. Use curly braces around the script block of your foreach loop. :wink:

And BTW: To set the sAMAccountName you can use the parameter -SamAccountName directly.