Score:0

How to update Azure AD MS Group Mail and ProxyAddresses field using PowerShell

in flag

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.

Score:1
tl flag

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.

in flag
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).
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.