export email address as array list

Copper Contributor

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

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.

@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.

 

@Vasil Michev I am running this in Remote exchange powershell.