An Azure service that is used to automate, configure, and install updates across hybrid environments.
hi Tyler Wakefield & thx for sharing urs issue here at Q&A portal,
For this job, I’d avoid the ExchangeOnlineManagement module in Azure Automation if possible.
Add-DistributionGroupMember is an Exchange cmdlet, so it depends on Exchange Online PowerShell session behavior. Azure Automation + EXO module version/runtime combos can be painful, esp PS 7.2. The Maximum retry count reached error usually means the EXO REST/remote session connection is failing/retrying, not that the group add itself is wrong.
Since u already have app-only auth, the cleaner route is Microsoft Graph if the target is a Microsoft 365 group. But if it’s a classic Exchange distribution list, Graph won’t fully replace Add-DistributionGroupMember. That’s the annoying split.
For classic DLs, use Exchange Online PowerShell app-only auth with certificate auth instead of client secret/access token. That’s the more supported automation pattern
Connect-ExchangeOnline `
-AppId $applicationID `
-CertificateThumbprint $certThumbprint `
-Organization 'pereviewsoftware.com'
Add-DistributionGroupMember -Identity $groupName -Member $username
A couple things I’d change in ur script
Use $username or user UPN for -Member, not the Graph object id. Exchange cmdlets usually resolve mail-enabled identity better by SMTP/UPN.
Don’t mix MSAL token + Connect-ExchangeOnline -AccessToken unless u really have to. In Automation, cert-based Connect-ExchangeOnline is less cursed.
For PS 7.2 in Azure Automation, make sure the EXO module version is supported in that runtime and imported into the Runtime environment, not just the Automation Account legacy modules area. Module UI saying Available doesn’t always mean that runtime can load it. Cute, right.
If this must be triggered from Power Automate, Power Automate > webhook > Azure Automation runbook is fine. Just keep the runbook auth as EXO app-only certificate auth. That should be way more stable than trying to hand-roll tokens for Exchange.
rgds,
Alex
&
If my answer was helpful pls mark it and additional thx if u follow me at Q&A portal
and at my blog https://ctrlaltdel.blog/