Reply
Division
Visitor 1

Exporting ALL tenants with all users and licenses

Hi everyone,

 

Since the Microsoft Teams license is a trial we want to know how to create an export of all our tenants with all users and their licenses so we can see which users are in need of a Microsoft Teams license when the trial ends.

4 REPLIES 4
VisitorChan
Visitor 1

#Establish a PowerShell session with Office 365 - create the relevant folder dir needed for the file location - you can edit the [$CSVpath = "C:\Temp\UserLicenseReport.csv"] line to customize.

#***Start of script***

Install-Module MSOnline
Import-Module MSOnline
Connect-MsolService
$customers = Get-MsolPartnerContract -All
Write-Host "Found $($customers.Count) customers for $((Get-MsolCompanyInformation).displayname)." -ForegroundColor DarkGreen
$CSVpath = "C:\Temp\UserLicenseReport.csv"

foreach ($customer in $customers) {
Write-Host "Retrieving license info for $($customer.name)" -ForegroundColor Green
$licensedUsers = Get-MsolUser -TenantId $customer.TenantId -All | Where-Object {$_.islicensed}

foreach ($user in $licensedUsers) {
Write-Host "$($user.displayname)" -ForegroundColor Yellow
$licenses = $user.Licenses
$licenseArray = $licenses | foreach-Object {$_.AccountSkuId}
$licenseString = $licenseArray -join ", "
Write-Host "$($user.displayname) has $licenseString" -ForegroundColor Blue
$licensedSharedMailboxProperties = [pscustomobject][ordered]@{
CustomerName = $customer.Name
DisplayName = $user.DisplayName
Licenses = $licenseString
TenantId = $customer.TenantId
UserPrincipalName = $user.UserPrincipalName
}
$licensedSharedMailboxProperties | Export-CSV -Path $CSVpath -Append -NoTypeInformation
}
}

#***End of script***

JanoschUlmer
Microsoft

@Division Using delegated access permissions as CSP Partner and MSOnline Powershell there might be ways to get access on the data of all licenses provisioned in each of the managed customer tenants. You can open an advisory request if you are Silver/Gold Partner with advisory hours: https://aka.ms/technicalservices.

However, "users requiring Teams" would be user that have active usage on teams, afaik this won't be possible, or at least considerable more effort.

 

 

 

Kind regards, Janosch (Note: Leaving role as of March 2023, don't expect further answers. Connect with me via LinkedIn: https://linkedin.com/in/janoschulmer)
ShreyasGanesh
Microsoft

Hello, unfortunately this scenario is not supported today. Thanks!

HansV
Microsoft

You can't 😞