Hello All,
Had a recent request from a colleague to pull some information out of Exchange. He wanted the following information:
Username, Mailbox Database, OU, Company, CustomAttribute1
I originally wanted to do it as a one-liner so that the person could run it at leisure, so started looking at expressions, since Get-Mailbox doesn't give the Company or OrganizationalUnit properties. But ran into an issue I was wondering if I can get help on. I started out as so:
Get-Mailbox | Select-Object Name,Database,@{Name="Company";Expression={Get-User -Identity $_.samAccountName | Select-Object Company}}
Problem is the output ended up being like so:
| Name |
Database |
Company |
| ---- |
-------- |
------- |
| Darrin Henshaw |
HFXIGNEXMB1\HFX\HFX |
@{Company=Ignition} |
Note the formatting of the company field. I didn't play around with it too much, and ended up building a small script using custom objects to pull the info, but wanted to know for future how I do this. Thanks.