28
Apr

Export All SMPT addresses of M365 using Powershell

Exporting all SMTP addresses (emails and their aliases) from Office 365 (now Microsoft 365) can be essential for various reasons, particularly during migration processes, such as transitioning to another domain.

Below PowerShell Query for exporting all aliases in a CSV

You can use the below PowerShell query to export all email addresses and their aliases in a single CSV as a comma-delimited file. You can use Powershell ISE or simple Powershell to run the below cmdlet.

M365 Exchange online module should be installed on your system First then, connect Powershell using the below command and follow the onscreen instructions

Connect-ExchangeOnline

Then, Paste the below Cmdlet

Get-EXORecipient -ResultSize Unlimited | Select-Object PrimarySmtpAddress, DisplayName, RecipientType, RecipientTypeDetails, @{Name=”EmailAddresses”; Expression={($_.EmailAddresses | Where-Object {$_ -like “smtp*”} | ForEach-Object {$_ -replace “smtp:”,””}) -join “,”}} | Sort-Object DisplayName | Export-CSV “C:\Temp\All_user_SMPTys.csv”

Create a folder in drive C named “TEMP” or change the path as per your desire but make sure you have access to the path and path should exist. The below cmdlet will export CSV in Location “C:\Temp\” .

Here’s an elaboration on why it’s crucial:

  1. Migration Planning and Mapping: When migrating from one Microsoft 365 domain to another, or even to a different email platform, having a comprehensive list of all SMTP addresses is crucial. This list serves as a mapping file, ensuring that emails are correctly routed from the source to the destination during and after migration. Without an accurate mapping of SMTP addresses, there’s a risk of emails being lost or misdirected during the transition.
  2. Data Integrity and Continuity: Exporting SMTP addresses helps maintain data integrity and ensures continuity of communication during the migration process. By preserving all email addresses associated with user accounts, you can avoid disruptions in email communication and minimize the impact on productivity.
  3. User Identification and Verification: The exported list of SMTP addresses allows for easy identification and verification of users and their corresponding email addresses. This is particularly useful for large organizations with numerous users, ensuring that no email addresses are overlooked or omitted during the migration process.
  4. Compliance and Audit Purposes: Keeping a record of all SMTP addresses may be necessary for compliance with regulatory requirements or internal audit procedures. Having a documented list of email addresses facilitates compliance audits and ensures that all communication channels are accounted for during regulatory inspections or internal reviews.
  5. Troubleshooting and Support: In the event of migration-related issues or post-migration troubleshooting, having access to a complete list of SMTP addresses simplifies the process of identifying and resolving email-related issues. Support teams can use this information to quickly diagnose and address any email routing or delivery issues that may arise.
  6. Documentation and Documentation: Exporting SMTP addresses serves as documentation of the email infrastructure configuration at a specific point in time. This documentation is valuable for future reference, planning future migrations, or making configuration changes to the email environment.
  7. Risk Mitigation: Exporting SMTP addresses mitigates the risk of data loss or disruption during the migration process. By ensuring that all email addresses are accounted for and properly mapped, organizations can minimize the potential impact of migration-related errors or oversights.

In summary, exporting all SMTP addresses from Office 365 is essential for ensuring a smooth and successful migration process, maintaining data integrity, complying with regulatory requirements, and facilitating efficient troubleshooting and support. It’s a critical step in safeguarding email communication and minimizing disruptions during periods of organizational change.