I have the following script that will export all the Office 365 licenses per user that is enabled for a license to a CSV. The export will list each user and then the multiple licenses on the same row like this: There is not a set number of licenses for each user, users will have different licenses.
Instead of having them export on the same row, I need to have the license for each user on a separate row like this: How can I modify the script to make that happen?
#### All lincesed users###
$JobCollection = @()
$mbx = Get-MsolUser -all | Where-Object { $_.isLicensed -eq "TRUE" }
$count=0
$fullcount = ($mbx | measure-object).count
foreach ($M in $MBX) {
$count++
$search = $m.userprincipalname.tostring()
Write-progress -activity "Getting Calendar $count out of $fullcount --- $search " -percentcomplete (($count / $fullcount)*100) -status "Processing"
$License = (((Get-MsolUser -UserPrincipalName $M.userprincipalname).Licenses.accountskuid) -join ",")
#$queuelink = $job.reportingqueueuri.absoluteuri
#$jobID = $Job.jobid
$Jobs = New-Object psobject
$JObs | Add-Member -MemberType NoteProperty -Name UserPrincipalName -Value $M.userprincipalname
$JObs | Add-Member -MemberType NoteProperty -Name License -Value $license
$JobCollection += $jobs
}
$JobCollection | export-csv "C:\test\AllMBXlicensse.csv" -NoTypeInformation

