I’m trying to get all alias from our exchange server. I’m using the command :
Get-Mailbox | Select-Object DisplayName,@{Name=”EmailAddresses”;Expression={$.EmailAddresses |Where-Object {$ -LIKE “SMTP:*”}}} | Sort
when it output the display i get the displayname, and emailaddresses but the emailaddresses are in sring format.
I’m trying to figure out how to split the address and output them in this form:
Displayname emailaddresses
Jon smith jons@test .com
jon.smith@test .com
jsmith@test .com
But instead it displays all the emailaddresses in a string together. I want them seperated. I tried putting into a custom object and such but I had no luck.
Thanks
Chris
Well emailaddresses is an array, so when you try and cram that into a single property it gets concatenated together. If your goal is a csv or something and you want to emails on separate rows you might want to loop through each mailbox and for the extra emails just have a pscustom objects with empty properties save for the email.
Then export to csv and it should be formatted like so
And BTW: When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.
Thanks so much for leading me in the right direction. My only change that I needed to make to the above script was in the custom object section. Just needed emailaddress = $Email
I appreciate the quick response and help guys and thanks for the tip on adding code into the forum.
Cheers