Forum Discussion
Script to export to CSV all Mailboxes and SharedMailboxes
rootwontfallConfirmed this one has worked... just change the ResultSize to Unlimited
Get-Mailbox -ResultSize 10 | select displayname,UserPrincipalName,RecipientTypeDetails,@{Name='Mailbox Size';Expression={Get-MailboxStatistics $_.UserPrincipalName | Select TotalItemSize}},@{Name='Licenses';Expression={(Get-MsolUser -UserPrincipalName $_.UserPrincipalName | Select -ExpandProperty Licenses).AccountSKUID}} |Export-Csv -NoTypeInformation .\Desktop\Test.csv
- rootwontfallJun 11, 2019Copper Contributor
The licenses column still blank and I can't understand why.
I got one script (the one I used before) to give me that kind of information just like this:
Get-MsolUser -All |
Select DisplayName,UserPrincipalName,@{n="Licenses";e={$_.Licenses.AccountSKUid}} | Sort-Object DisplayName |
Export-Csv -Path C:\temp\MailboxesLicenciadas.csv -NoTypeInformationI tried it like this:
Get-Mailbox -ResultSize:Unlimited | select displayname,UserPrincipalName,RecipientTypeDetails,@{Name='Mailbox Size';Expression={Get-MailboxStatistics $_.UserPrincipalName | Select TotalItemSize}},@{Name='Licenses';Expression={Get-MsolUser -UserPrincipalName $_.UserPrincipalName | Select -ExpandProperty Licenses.AccountSKUID}} |Export-Csv -NoTypeInformation C:\temp\FullExport.csv
But I can't make it work in your script. Do you've any idea why?
- jerome317Jun 11, 2019Brass Contributor
rootwontfallYou're missing a parenthesis, order of operations.
(Get-MsolUser -UserPrincipalName $_.UserPrincipalName | Select -ExpandProperty Licenses).AccountSKUID
- rootwontfallJun 12, 2019Copper Contributor
Even making the following command:
Get-Mailbox -ResultSize:Unlimited | select displayname,UserPrincipalName,RecipientTypeDetails,@{Name='Mailbox Size';Expression={Get-MailboxStatistics $_.UserPrincipalName | Select TotalItemSize}},@{Name='Licenses';Expression={(Get-MsolUser -UserPrincipalName $_.UserPrincipalName | Select -ExpandProperty Licenses).AccountSKUID}} |Export-Csv -NoTypeInformation .\Desktop\Test.csv
It still gives me all columns right unless the column called "Licenses".
I've already tried to change the script but the result is the same...
I can't export licenses of each mailboxes.
Thanks for your help jerome317!