New Method to Retrieve Renewal Dates for Microsoft 365 Subscriptions
As part of my campaign to help people move off the old MSOL and AzureAD PowerShell modules to use the Microsoft Graph PowerShell SDK before Microsoft deprecates the modules, I wrote a script to demonstrate how to use the Graph SDK to create a licensing report for a tenant. One of the replies to the article observed that the output of the Get-MgSubscribedSku cmdlet didn’t provide the same information as the old Get-MsolSubscription cmdlet. Specifically, the SDK cmdlet doesn’t tell you the renewal date for a product (SKU).
Relief is now available, but not yet in an SDK cmdlet. Instead, you can fetch the renewal information using a new beta Graph subscriptions endpoint described in Vasil’s blog. This is different to the SubscribedSku API, which is what I think is the base for the Get-MgSubscribedSku cmdlet.
Practical Example of Displaying Renewal Dates for Microsoft 365 Subscriptions
As an example of how you might use the information, I took the output generated by the Get-MgSubscribedSku cmdlet and reformatted it so that it looks like the output from the Get-MsolSubscription cmdlet. The cmdlet lists the SKU part number, active units (available units), warning units (licenses that have expired or have another problem), and consumed units (licenses assigned to user accounts). I wanted to add the renewal date and number of days until the renewal date.
To fetch the renewal dates, I then use the Invoke-MgGraphRequest cmdlet to query the https://graph.microsoft.com/V1.0/directory/subscriptions endpoint. If a SKU has a renewal date, it is in the nextLifecycleDateTime property. Some SKUs that don’t expire (like Power BI standard) don’t have renewal dates. Here’s an example of the information for a Viva Topics subscription that has a renewal date.
Name Value ---- ----- skuId 4016f256-b063-4864-816e-d818aad600c9 skuPartNumber TOPIC_EXPERIENCES createdDateTime 05/02/2021 18:09:21 totalLicenses 25 id de6eac24-b4b7-4f7e-abeb-9e4f10b36883 serviceStatus {System.Collections.Hashtable, System.Collections.Hashtable, System.Collections.Hasht... ocpSubscriptionId eeda0292-642e-4901-9825-aa7dfc9b0efc isTrial True status Warning nextLifecycleDateTime 30/07/2023 14:53:22
To make it easy to lookup the renewal data for a SKU, I created a hash table to store SKU identifiers and renewal dates. The final step is to loop through the SKU information and add the renewal date. Here’s the code:
Connect-MgGraph -Scopes Directory.Read.All -NoWelcome # Get the basic information about tenant subscriptions [array]$Skus = Get-MgSubscribedSku $SkuReport = [System.Collections.Generic.List[Object]]::new() ForEach ($Sku in $Skus) { $DataLine = [PSCustomObject][Ordered]@{ SkuPartNumber = $Sku.SkuPartNumber SkuId = $Sku.SkuId ActiveUnits = $Sku.PrepaidUnits.Enabled WarningUnits = $Sku.PrepaidUnits.Warning ConsumedUnits = $Sku.ConsumedUnits } $SkuReport.Add($Dataline) } # Get the renewal data $Uri = "https://graph.microsoft.com/V1.0/directory/subscriptions" [array]$SkuData = Invoke-MgGraphRequest -Uri $Uri -Method Get # Put the renewal information into a hash table $SkuHash = @{} ForEach ($Sku in $SkuData.Value) { $SkuHash.Add($Sku.SkuId,$Sku.nextLifecycleDateTime) } # Update the report with the renewal information ForEach ($R in $SkuReport) { $DaysToRenew = $Null $SkuRenewalDate = $SkuHash[$R.SkuId] $R | Add-Member -NotePropertyName "Renewal date" -NotePropertyValue $SkuRenewalDate -Force If ($SkuRenewalDate) { $DaysToRenew = -(New-TimeSpan $SkuRenewalDate).Days $R | Add-Member -NotePropertyName "Days to renewal" -NotePropertyValue $DaysToRenew -Force } } $SkuReport | Format-Table SkuPartNumber, ActiveUnits, WarningUnits, ConsumedUnits, "Renewal date", "Days to renewal" -AutoSize
Figure 1 shows the output.

Future SDK Cmdlet Will Probably Come
Obviously, it would be much better if an SDK cmdlet exposed renewal dates for Microsoft 365 subscriptions. Given that the subscriptions endpoint is new, it’s likely that a new SDK will appear after Microsoft’s AutoRest process runs to process the metadata for the endpoint. I’d expect this to happen sometime in the next few weeks.
In the interim, if access to subscription renewal dates is holding up the migration of some old MSOL or AzureAD scripts, a solution is available.
Insight like this doesn’t come easily. You’ve got to know the technology and understand how to look behind the scenes. Benefit from the knowledge and experience of the Office 365 for IT Pros team by subscribing to the best eBook covering Office 365 and the wider Microsoft 365 ecosystem.
Thanks for the great explanation, now we have the renewal date is there a way to figure out the charging period of the Subscription.
So we can report on what it is that needs purchasing to renew the expiring subscription.
Charging periods are usually per year… so your renewal date is the end of the charging period.