0

I need to update email address domain for all Azure AD Groups (of all types Unified, Dynamic ... ) and I am using PowerShell 7 with latest stable AzureAD module.

I have an issue with setting new value to "Mail" and "ProxyAddresses" properties using Set-AzureADMSGroup cmdlet. Can somebody help / provide information or example on how to correctly set those properties, since documentation is not clear for this. https://docs.microsoft.com/en-us/powershell/module/azuread/set-azureadmsgroup?view=azureadps-2.0

In case this is not possible with this cmdlet, then I need to use Exchange Online Powershell to manage all groups via seperated cmdlet regarding the GroupTypes ?

Import-Module AzureAD -UseWindowsPowerShell
Connect-AzureAD

$AzureADMSGroups = Get-AzureADMSGroup -All:$true -Filter "mail ge ' '"

foreach ($AzureADGroup in $AzureADGroups) {
    $newMail = $AzureADGroup.Mail.Replace('olddomain.com','newdomain.com')
    $AzureADGroup | Set-AzureADMSGroup -Replace @(Mail = $newMail } }
}

Error which I have is that -Replace parametar is not found. I also tried:

$AzureADGroup.Mail = $newMail
$AzureADGroup | Set-AzureADMSGroup

Which does not throw any output or error, but value is not changed in Azure AD. I also need to update ProxyAddresses field/property in the same way.

Hrvoje Kusulja
  • 254
  • 1
  • 11

1 Answers1

1

Set-AzureADMSGroup cmdlet does not seem to support changing email addresses, according to documentation here.

$AzureADGroup.Mail = $newMail 

It just changes the value of variable.

Try using Exchange Online module

     Set-UnifiedGroup
     Set-Group 
     Set-DistributionGroup
     Set-DynamicDistributionGroup

etc.

If you tell me exactly what you need, I could help you write it.

MMNandM
  • 46
  • 5
  • Thank you, this is clear and working. However I wanted to find a way how to use AzureADMSGroup for setting primary email and proxyAddress (Email Addresses). – Hrvoje Kusulja Jan 07 '22 at 15:21