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.