find the subcribed date of a license per user

Copper Contributor

I'm in charge of the MS35 administration for a non-profit and non-governmental Organization. We've got several local services and I need to report to each local service the cost of the licenses used by its staff : MS 365 standard, premium, Power BI pro,...
I can get the number of licences per local service which are used today, but because these numbers change every month, I need to get the history : the subscribed date and the end date for each licenses.
Where can I find these informations in the MS365 admin database ?
Maybe a report with these informations or a powershell script already exist, but I've not found.
Pls do not answer with proposals of paid tools : I'm looking either for clues to find the informations in the MS 365 database or free of charge PS scripts.
I thank you

5 Replies



You first try in M365 Admin Center and your CSP partner


Thank you for your time, but it doesn't answer my question

Hi, have you tried to access, and log in using your Microsoft email to access billing history?
Hello Pierre-Yves, To retrieve historical license information, including subscription and end dates, you can use PowerShell and Microsoft Graph API. Here is a basic outline of the steps you can follow:

### Prerequisites:
1. Ensure you have the required permissions to access Microsoft Graph API.
2. Install the MSOnline module for PowerShell (if not installed).

### PowerShell Script:
# Install the MSOnline module (if not installed)
# Install-Module -Name MSOnline -Force -AllowClobber

# Import MSOnline module
Import-Module MSOnline

# Connect to MSOnline
$credential = Get-Credential
Connect-MsolService -Credential $credential

# Get all users
$users = Get-MsolUser -All

foreach ($user in $users) {
$userPrincipalName = $user.UserPrincipalName

# Get license information for the user
$licenses = Get-MsolUser -UserPrincipalName $userPrincipalName | Select-Object -ExpandProperty Licenses

foreach ($license in $licenses) {
$serviceName = $license.AccountSkuId
$subscribedDate = $license.SubscribedPlans[0].AssignedTimestamp
$endDate = $license.SubscribedPlans[0].ExpiryTimestamp

# Output the information (you can modify this part as needed)
Write-Output "User: $userPrincipalName, Service: $serviceName, Subscribed Date: $subscribedDate, End Date: $endDate"

# Disconnect from MSOnline

### Notes:
- Modify the output section based on your reporting needs.
- Ensure you have the necessary permissions to execute these commands.
- Make sure to handle authentication securely, especially if you plan to schedule or automate the script.

This script uses the MSOnline PowerShell module to connect to MS 365 and retrieve license information for each user. You may need to adjust it based on your specific requirements and environment.

Remember to test the script in a safe environment before running it in production. Additionally, Microsoft Graph API may provide more advanced capabilities for historical data, but it requires more complex authentication and permission handling.

Have a great day lo Pierre-Yve!


Thank you very much Elgin. I'll try in the next following days.