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.

31
Oct

Add Aliases in O365 using Powershell

Add users aliases in O365 (Powershell)

Things to Remember while adding aliases to MS O365 via PowerShell while running our CMD-lets

  • Prepare a user list for adding aliases in CSV format.
  • First Column will have primary email address and second will have aliases.
  • In the CSV, create header for primary email address as Mailbox and Alias email header will be named as NewEmailAddress
  • Create folder in C drive and name it as temp.
  • We are saving csv as aliases.csv
  • Connect the Exchnage powershell and Run below command. Click here to setup and connect Online powershell.

Adding aliases we can achieve by running the command in two ways but both will have the same result. The difference is working with PowerShell script and running it into Powershell ISE and another is via using Powershell CMD

First Method

By Importing everything from CSV to Variable named $user and then process our request. Also, you can save it as a PowerShell script like aliases.ps and then run it using windows Powershell ISE Or copy/paste the below code to the PowerShell console. Click here how to setup PowerShell for using O365.

Copy and past below CMD to Powershell or Copy/past it into notepad, save it as “Alias.ps” then open it in Powershell ISE. Click here how to connect PowerShell ISE for using O365.

$users = Import-csv ‘C:\temp\aliases.csv’
foreach($user in $users)
{
Set-Mailbox “$($user.Mailbox)” -EmailAddresses @{add=”$($user.NewEmailAddress)”}
}

Second Method

Below CMD will use to direct apply changes without using any variable. Copy the below command and past it to Powershell CMD. Connect power with exchange online (EXO) before past the below command.

Import-csv ‘C:\temp\aliases.csv’
foreach{
Set-Mailbox $_.Mailbox -EmailAddresses @{add=”$_.NewEmailAddress”}
}

Please share and Like if it helps you or Reply in comment if something issue missing.