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

%3CLINGO-SUB%20id%3D%22lingo-sub-730888%22%20slang%3D%22en-US%22%3Epowershell%20script%20to%20export%20display%20name%20and%20primary%20smtp%20address%20of%20all%20users%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-730888%22%20slang%3D%22en-US%22%3E%3CP%3Ewhat%20is%20the%20powershell%20script%20to%20export%20display%20name%20and%20primary%20smtp%20address%20of%20all%20users%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ethanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-730888%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAdmin%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExchange%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-730909%22%20slang%3D%22en-US%22%3ERe%3A%20powershell%20script%20to%20export%20display%20name%20and%20primary%20smtp%20address%20of%20all%20users%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-730909%22%20slang%3D%22en-US%22%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F61448%22%20target%3D%22_blank%22%3E%40Marvin%20Oco%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fo365info.com%2Fexport-and-display-information-about-email-addresses-using-powershell-office-365-part-6-13%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fo365info.com%2Fexport-and-display-information-about-email-addresses-using-powershell-office-365-part-6-13%2F%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3ESee%20section%20-%20Export%20PowerShell%20command%20output%20to%20a%20CSV%20file%3CBR%20%2F%3E%3CBR%20%2F%3EGet-Mailbox%20-ResultSize%20Unlimited%20%7CSelect-Object%20DisplayName%2CPrimarySmtpAddress%2CEmailAddresses%2CEmailAddresses%20%7C%20Export-CSV%20C%3A%5CTemp%5C%22Exchange%20Online%20recipients.CSV%22%20%E2%80%93NoTypeInformation%20-Encoding%20UTF8%3CBR%20%2F%3E%3CBR%20%2F%3EHope%20that%20helps%3CBR%20%2F%3E%3CBR%20%2F%3EBest%2C%20Chris%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-730974%22%20slang%3D%22en-US%22%3ERe%3A%20powershell%20script%20to%20export%20display%20name%20and%20primary%20smtp%20address%20of%20all%20users%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-730974%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F61448%22%20target%3D%22_blank%22%3E%40Marvin%20Oco%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20can%20run%20below%20code%20to%20export%20all%20office%20365%20mailboxes'%20DisplayName%20and%20PrimarySMTPAddress%20to%20CSV%20file.%3C%2FP%3E%3CPRE%3EGet-Mailbox%26nbsp%3B%20-Resultsize%20Unlimited%20%7C%20select%20DisplayName%2CPrimarySMTPAddress%20%7C%20Export-csv%20E%3A%5CO365Users.csv%20-NoType%20-Append%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20need%20additional%20attributes%20like%20license%20details%2C%20mfa%20status%20and%20mailbox%20permissions%2C%20you%20can%20refer%20this%20blog%3A%20%3CA%20href%3D%22https%3A%2F%2Fo365reports.com%2F2019%2F05%2F09%2Fexport-office-365-users-mfa-status-csv%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EExport%20Office%20365%20user%20details%20report%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
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