Forum Discussion
rootwontfall
Jun 08, 2019Copper Contributor
Script to export to CSV all Mailboxes and SharedMailboxes
Hi, I'm trying to make a new script in Powershell to display (for a report) the following attributes in a CSV table like this: DisplayName UserPrincipalName Licenses RecipientTypeDetails ...
jerome317
Brass Contributor
Here you go!
Get-Mailbox -ResultSize Unlimited | Select DisplayName,UserPrincipalName,RecipientTypeDetails,TotalItemSize,@{Name='Licenses';Expression={(Get-MsolUser -UserPrincipalName $_.UserPrincipalName | Select -ExpandProperty Licenses).AccountSkuID}} | Export-CSV -NoTypeInformation $env:USERPROFILE\Desktop\File.CSV
rootwontfall
Jun 10, 2019Copper Contributor
I tried the script but that's the same problem that I had. Exporting that kind of information it only displays the following attributes right:
DisplayName UserPrincipalName RecipientTypeDetails
The other two columns (TotalItemSize and Licenses) are all blank.
To get the TotalItemSize I've to use get-mailboxstatistics am I right?
- jerome317Jun 10, 2019Brass Contributor
That's right... woops, I only tried displayname and licenses and didn't confirm the rest. I'd say do the same thing with TotalItemSize using the format when I retrieve the licenses.
It does help if you can post your actual command 😉
@{Name='Licenses';Expression={(Get-MsolUser -UserPrincipalName $_.UserPrincipalName | Select PropertyHere)