Install-Module -Name AzureAD
Import-Module  AzureAD
Connect-AzureAD
 
Install-Module MSOnline
Connect-MsolService
 
Get-MsolPartnerContract -All | Select-Object TenantId,name
 
Get-MsolSubscription -TenantId  a-b-c-d-e|select Datecreated, SkuPartnumber, nextlifecycledate, status, totallicenses
 
 
foreach ($val in ( Get-MsolPartnerContract -All | Select-Object TenantId,name)) { echo $val.name; Get-MsolSubscription -TenantId $val.TenantId |select SkuPartnumber, nextlifecycledate, status, totallicenses}

Sources

https://learn.microsoft.com/en-us/microsoft-365/enterprise/connect-to-microsoft-365-powershell?view=o365-worldwide

https://learn.microsoft.com/en-us/microsoft-365/enterprise/manage-microsoft-365-tenants-with-windows-powershell-for-delegated-access-permissio?view=o365-worldwide