Forum Discussion
alias
Hi i have used the below syntax
Import-csv C:\emails.csv | % { Get-Mailbox $_.SMTP | select Alias, EmailAddresses }
in emails.csv files i have email addresses in the below format,i have tested with 2 emails in csv file
user1@mydomain.com
user2@mydomain.com
The output i am getting is for all the email addresses it is not picking from the csv file.
i only want to pull the report from csv file
Alias EmailAddresses
----- --------------
user1 {smtp:user1.test@mydomain.com, SMTP:user1@mydomain.com}
user2 {smtp:user2.test@mydomain.com, SMTP:user2@mydomain.com}
user4 {SMTP:user4@mydomain.com}
user5 {SMTP:user5@mydomain.com}
user6 {SMTP:user6@mydomain.com}
user7 {SMTP:user7@mydomain.com}
user8 {SMTP:user8@mydomain.com
And also i am not able to export to proper format when i tried below syntax
Import-csv C:\emails.csv | % { Get-Mailbox $_.SMTP | select Alias, EmailAddresses } | export-csv C:\output.csv -NoTypeInformation
even i tried the below syntax, i am not getting alias name and i am getting output for only the first email id in csv file
for example in emails.csv i have user1@mydomain.com and user2@mydomain.com, i am getting output for first email id.
$users=import-csv C:\emails.csv
ForEach($user in $users){
Get-Recipient $user.email | Select Name -ExpandProperty EmailAddresses |export-csv C:\output.csv -notypeinformation
}
- VasilMichevJul 28, 2018MVP
Well I cannot guess what you have in the CSV, my example above assumes that all the addresses are under a column named "SMTP". If you are using another name, simply replace it accordingly. Or use the script I linked to.