Forum Discussion

Azhar_pasha's avatar
Azhar_pasha
Copper Contributor
Mar 01, 2021

Powershell command to extract UPN and primary SMTP from a set of Display name in csv file.

Hello All,

 

Please provide me PowerShell command to extract UPN and primary SMTP from a set of Display name in csv file. (office 365)

  • This is a quick example on how to get the user information from a displayname

    Get-MsolUser -SearchString 'UserDisplayName' | select UserPrincipalName,ProxyAddresses
  • farismalaeb's avatar
    farismalaeb
    Steel Contributor
    This is a quick example on how to get the user information from a displayname

    Get-MsolUser -SearchString 'UserDisplayName' | select UserPrincipalName,ProxyAddresses
    • Azhar_pasha's avatar
      Azhar_pasha
      Copper Contributor

      Hi farismalaeb ,

       

      Thanks for the below command, However, I was trying on exchange online shell. Hit with an idea to use like this.

       

      Import-Csv "csv path" | foreach{Get-Mailbox -Identity $_.displaynames} | select *UserPrincipalName*, *PrimarySmtpAddress* | Export-Csv "export path"

Resources