Forum Discussion

vignesh_Learn's avatar
vignesh_Learn
Copper Contributor
Jan 28, 2021

export email address as array list

I am trying to export a list of users email address in array format..

say I have 10 users in a CSV file (displayname)

Need a command to export their emailaddresses in array type

example:

colum1 should have name

column2 should have 1 smtpaddress

colum 3 should have the other smtpaddress

 

can someone help pls

3 Replies

  • farismalaeb's avatar
    farismalaeb
    Iron Contributor

    vignesh_Learn 

     

    $Myusers=@("Firstname LastName","FirstName1 LastName1")
    $Myusers.foreach{Get-ADUser -Properties mail,proxyAddresses -Filter "displayname -like '$_'" | ft mail,proxyAddresses  }

     

     

    Use this method if you don't have Exchange Management Shell or want to get the information via Active Directory.

     

  • Use PrimarySmtpAddress for the second column, and something like ($_.EmailAddresses -join ";") for the third. The syntax will depend on whether you are running this against EMS or Remote Exchange PowerShell.

Resources