I'm trying to export all email addresses from my tenant, including mailboxes, shared mailboxes, M365 groups, distribution lists, dynamic distribution lists, and mail-enabled security groups, to a CSV file using the Microsoft Graph PowerShell SDK. I used to rely on older modules like MSOnline and AzureAD, but now I need to adapt my script for Graph. I've noticed that my current implementation is missing several addresses in the CSV compared to my previous exports. Can anyone share their experiences or solutions on how to export all these email addresses correctly? Also, here's a portion of my old and new scripts for context!
1 Answer
Have you looked into using `Get-Recipient`? It simplifies fetching all mail-enabled objects in one go, which might make your life easier when exporting.
Yes, but for automation, it’s wiser to stick with the Graph SDK. It’s just more future-proof.