powershell script to export display name and primary smtp address of all users

Super Contributor

what is the powershell script to export display name and primary smtp address of all users?

 

thanks

2 Replies
Hi @Marvin Oco

https://o365info.com/export-and-display-information-about-email-addresses-using-powershell-office-36...

See section - Export PowerShell command output to a CSV file

Get-Mailbox -ResultSize Unlimited |Select-Object DisplayName,PrimarySmtpAddress,EmailAddresses,EmailAddresses | Export-CSV C:\Temp\"Exchange Online recipients.CSV" –NoTypeInformation -Encoding UTF8

Hope that helps

Best, Chris

@Marvin Oco 

You can run below code to export all office 365 mailboxes' DisplayName and PrimarySMTPAddress to CSV file.

Get-Mailbox  -Resultsize Unlimited | select DisplayName,PrimarySMTPAddress | Export-csv E:\O365Users.csv -NoType -Append

 

If you need additional attributes like license details, mfa status and mailbox permissions, you can refer this blog: Export Office 365 user details report