How to Find the Time Stamp for the License Assigned in M365/O365 for an End User or for the Entire Tenant

 

Below is the Step by Step Instruction for getting the Time Stamp for the End User License Assignment for any user. The commands can be used to get the output for all the Licenses we only need to change the License SKU in the Script and we should be able to get output.


1. First Step is to Install the Azure AD Module.

         Open the Powershell

         Run the Command Install-Module -Name AzureAD

         If Prompted Press Yes and Install the Module

 

2. Next Step is to Connect to Office 365 Admin Portal via PowerShell

         In case the MS Online Powershell is missing we need to install the same. To install the MS Online Powershell Open the Powershell in the Admin Mode and run the following Command

         Install-Module MSOnline

         To Connect to the MSOnline we need to run the next Command

         Import-Module msonline

         Connect-MsolService -Credential $cred

 

When prompted please enter the Office 365 Admin Password for the Connecting.

 

3. Now we need to identify the SKU for which we need to get the TimeStamp.

         After we are connected to the Microsoft Online Portal via Powershell we need to run the following command

         Get-MsolAccountSku

 

Output will be as follows: -

 AccountSkuId                                                    ActiveUnits WarningUnits ConsumedUnits

------------                                                            -----------         ------------         -------------

reseller-account:STREAM                                  1000000               0                         0

reseller-account:ENTERPRISEPREMIUM                 25                    0                        25

reseller-account:WINDOWS_STORE                         0                  0                       0

reseller-account:PHONESYSTEM_VIRTUALUSER    24                0                        4

reseller-account:TEAMS_COMMERCIAL_TRIAL  500000           0                        2

 

4. Now for whichever License we want to get the Time Stamp for the Entire Tenant we need to run the following Script. In the Script we need to modify the SKU separately and also the Location where you want to save the file.

 

 

$CurrentDate = Get-Date

$CurrentDate = $CurrentDate.ToString('dd-MM-yyyy_hh-mm')

$sku = "ENTERPRISEPREMIUM"

 

$cred = Get-Credential

Connect-AzureAD -Credential $cred

 

$e3 = Get-AzureADSubscribedSku | ? {$_.SkuPartNumber -like "*$sku*"} | select -expand SkuPartnumber

$planE3 = Get-AzureADSubscribedSku | ? {$_.SkuPartNumber -like "*$sku*"} | select -expand Serviceplans | select -expand ServicePlanId

 

$users = Get-AzureADUser -All:$True

$count = $users.count

 

$report = @()

 

$i = 0

foreach ($u in $users)

{

    $i++; Write-Host "$i of $count"

 

    $upn = $u.UserPrincipalName

    $comp= $u.CompanyName

    $state= $u.State

 

    $plans = $u | select -expand AssignedPlans

 

    $plans1 = foreach ($p in $planE3){ $plans | ? {$_.ServicePlanId -like "*$p*"} }

 

    if ($?)

    {

        foreach ($plan in $plans1)

        {

            $when = $plan | select -expand AssignedTimeStamp

            $service = $plan.Service

            $servicePlanId = $plan.ServicePlanId

 

           

            $report += New-Object psobject -Property @{UserPrincipalName = $upn; AssignedTimestamp = $when; `

                    Service = $service; CompanyName = $comp; State = $state; SkuPartnumber = $e3; ServicePlanId = $servicePlanId}

           

        }

    }

}

 

$report | select UserPrincipalName,CompanyName,State,AssignedTimestamp,SkuPartnumber,Service | Export-CSV C:\licences_$CurrentDate.csv –noType -Encoding:UTF8 -Delimiter ";"

 

5. In case we want to get the Time Stamp for the Individual User we need to run the following commands

 

         Connect-AzureAD

         (Get-AzureADUser -SearchString userid@domain.com).AssignedPlans

 

 

Note: -

1.    Kindly change the path of the File in case we are running the output for all the users in the Tenant according to the destination required.

2.    In the All User Script please change the SKU of the License which is assigned to the user otherwise the output will be a Blank File.

Comments

Popular posts from this blog

Multiple Instances Microsoft Teams Application

Delegate Features in Microsoft Teams Get a Major Overhaul, Including Call Barging

Microsoft Audio Conferencing for Microsoft Teams