Forum Discussion
Script to export to CSV all Mailboxes and SharedMailboxes
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 -NoTypeInformation
I 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?
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!
- jerome317Jun 12, 2019Brass ContributorWeird. Exact script I ran and shows results, License is blank if it is a Shared/Resource mailbox.
So if you run a separate command using this, does it show licenses?
Get-MsolUser -UserPrincipalName YOUR_UPN@contoso.com | select DisplayName,Licenses- DeepakRandhawaJun 12, 2019Iron Contributor
Did you use Connect-MsolService to be able to run Get-MsolUser part of the cmd ?
I used the same set of cmdlets and was able to get required data.
Deepak