Overview of E3 Licences with a timestamp

%3CLINGO-SUB%20id%3D%22lingo-sub-787783%22%20slang%3D%22en-US%22%3EOverview%20of%20E3%20Licences%20with%20a%20timestamp%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-787783%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20trying%20to%20get%20an%20overview%20of%20when%20E3%20Licences%20were%20assigned%20to%20all%20my%20users%20via%20powershell.%20I'm%20going%20around%20in%20circles.%20By%20using%20this%3A%26nbsp%3BGet-MsolAccountSku%2C%20I%20get%20the%20number%20of%20licences%20per%26nbsp%3BAccountSkuId.%20But%20I'm%20having%20difficulty%20combing%20the%20number%20the%20licences%20and%20timestamp.%20Has%20anyone%20done%20this%20via%20powershell%3F%20A%20simple%20report%20with%20the%20number%20of%20E3%20Licences%20with%20a%20timestamp%20of%20when%20they%20were%20assigend%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-787783%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAdmin%20center%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-788075%22%20slang%3D%22en-US%22%3ERe%3A%20Overview%20of%20E3%20Licences%20with%20a%20timestamp%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-788075%22%20slang%3D%22en-US%22%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F387248%22%20target%3D%22_blank%22%3E%40Byrdie68%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3ESee%20article%3CBR%20%2F%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FAdmin-Center%2FSee-the-assignment-date-of-a-license%2Fm-p%2F153369%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FAdmin-Center%2FSee-the-assignment-date-of-a-license%2Fm-p%2F153369%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3EAs%20Vasil%20mentions%20in%20the%20thread%2C%20you%20can%20check%20the%20assignment%20date%20via%20the%20Azure%20AD%20PowerShell%20module%3CBR%20%2F%3E%3CBR%20%2F%3EHope%20that%20answers%20your%20question.%3CBR%20%2F%3E%3CBR%20%2F%3EBest%2C%20Chris%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-788528%22%20slang%3D%22en-US%22%3ERe%3A%20Overview%20of%20E3%20Licences%20with%20a%20timestamp%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-788528%22%20slang%3D%22en-US%22%3E%3CP%3EThat%2C%20or%20you%20can%20crawl%20the%20Azure%20AD%20logs%2FO365%20unified%20log%20for%20any%20%22assign%20license%22%20activities.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-789097%22%20slang%3D%22en-US%22%3ERe%3A%20Overview%20of%20E3%20Licences%20with%20a%20timestamp%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-789097%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F58%22%20target%3D%22_blank%22%3E%40Vasil%20Michev%3C%2FA%3E%26nbsp%3BIs%20it%20not%20a%20bit%20easier%3F%20I'm%20doing%20the%20following%20but%20using%20the%20sharepoint%20online%20ID%20to%20get%20an%20overview%20of%20the%20E3%20licences.%20I'm%20also%20trying%20to%20get%20when%20users%20could%20have%20switched%20from%20an%20E2%20to%20E3%20licence.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%24users%20%3D%20Get-AzureADUser%20-All%3A%24True%3C%2FP%3E%3CP%3E%24count%20%3D%20%24users.count%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%24report%20%3D%20%40()%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%24i%20%3D%200%3C%2FP%3E%3CP%3Eforeach%20(%24u%20in%20%24users)%3C%2FP%3E%3CP%3E%7B%3C%2FP%3E%3CP%3E%24i%2B%2B%3B%20%23Write-Host%20%22%24i%20of%20%24count%22%3A%20%24u.UserPrincipalName%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%24upn%20%3D%20%24u.UserPrincipalName%3C%2FP%3E%3CP%3E%24comp%3D%20%24u.CompanyName%3C%2FP%3E%3CP%3E%24state%3D%20%24u.State%3C%2FP%3E%3CP%3E%24licenses%20%3D%20%24u%20%7C%20select%20-expand%20AssignedLicenses%3CBR%20%2F%3Eforeach%20(%24l%20in%20%24licenses)%7B%3CBR%20%2F%3E%24license%20%3D%20%22%22%3CBR%20%2F%3Eif%20(%24l.skuId%20-eq%20%2218181a46-0d4e-45cd-891e-60aabd171b4e%22)%7B%24license%20%3D%20%22E1%22%7D%3CBR%20%2F%3Eif%20(%24l.skuId%20-eq%20%226634e0ce-1a9f-428c-a498-f84ec7b8aa2e%22)%7B%24license%20%3D%20%22E2%22%7D%3CBR%20%2F%3Eif%20(%24l.skuId%20-eq%20%226fd2c87f-b296-42f0-b197-1e91e994b900%22)%7B%24license%20%3D%20%22E3%22%7D%3CBR%20%2F%3Eif%20(%24l.skuId%20-eq%20%22c7df2760-2c81-4ef7-b578-5b5392b571df%22)%7B%24license%20%3D%20%22E5%22%7D%3CBR%20%2F%3Eif%20(%24license%20-ne%20%22%22)%7B%3CBR%20%2F%3E%3CBR%20%2F%3E%24plans%20%3D%20%24u%20%7C%20select%20-expand%20AssignedPlans%3CBR%20%2F%3E%24firstdaySharePoint%20%3D%20%22%22%3CBR%20%2F%3E%24firstdayhigherlicense%20%3D%20%22%22%3CBR%20%2F%3Eforeach%20(%24p%20in%20%24plans)%7B%3CBR%20%2F%3Eif%20(%24p.ServicePlanId%20-eq%20%22e95bec33-7c88-4a70-8e19-b10bd9d0c014%22)%7B%3CBR%20%2F%3E%24firstdaySharePoint%20%3D%20%24p.AssignedTimestamp%3B%3CBR%20%2F%3E%7D%3CBR%20%2F%3Eif%20(%24p.ServicePlanId%20-eq%20%22efb87545-963c-4e0d-99df-69c6916d9eb0%22%20-and%20%24p.CapabilityStatus%20-eq%20%22Enabled%22)%7B%3CBR%20%2F%3E%24firstdayhigherlicense%20%3D%20%24p.AssignedTimestamp%3B%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%3CBR%20%2F%3E%7D%3CBR%20%2F%3EWrite-Host%20%24u.UserPrincipalName%20%24license%20%24firstdaySharePoint%20%24firstdayhigherlicense%3CBR%20%2F%3E%24report%20%2B%3D%20New-Object%20psobject%20-Property%20%40%7BUserPrincipalName%20%3D%20%24u.UserPrincipalName%3B%20FirstOffice365License%20%3D%20%24firstdaySharePoint%3B%20FirstHigherLicense%20%3D%20%24firstdayhigherlicense%3B%20CompanyName%20%3D%20%24u.CompanyName%3B%20State%20%3D%20%24u.State%3B%20CurrentLicense%20%3D%20%24license%7D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%7D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%7D%3CBR%20%2F%3E%24report%20%7C%20select%20UserPrincipalName%2CCompanyName%2CState%2CFirstOffice365License%2CCurrentLicense%20%7C%20Export-CSV%20C%3A%5Ctemp%5Clicences_%24CurrentDate.csv%20%E2%80%93noType%20-Encoding%3AUTF8%20-Delimiter%20%22%3B%22%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-789467%22%20slang%3D%22en-US%22%3ERe%3A%20Overview%20of%20E3%20Licences%20with%20a%20timestamp%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-789467%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20covers%20the%20individual%20service%20plans%2C%20not%20the%20license%20assignment%20as%20a%20whole%2C%20which%20I%20believe%20was%20the%20original%20ask.%20Those%20can%20have%20different%20values%2C%20and%20in%20general%20the%20license%20itself%20can%20be%20assigned%2Fremoved%20multiple%20times%20-%20the%20AAD%20cmdlets%20will%20only%20show%20you%20the%20latest%20timestamp.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hi, 

 

I'm trying to get an overview of when E3 Licences were assigned to all my users via powershell. I'm going around in circles. By using this: Get-MsolAccountSku, I get the number of licences per AccountSkuId. But I'm having difficulty combing the number the licences and timestamp. Has anyone done this via powershell? A simple report with the number of E3 Licences with a timestamp of when they were assigend?

 

Thanks. 

4 Replies
Highlighted
Hi @Byrdie68

See article

https://techcommunity.microsoft.com/t5/Admin-Center/See-the-assignment-date-of-a-license/m-p/153369

As Vasil mentions in the thread, you can check the assignment date via the Azure AD PowerShell module

Hope that answers your question.

Best, Chris
Highlighted

That, or you can crawl the Azure AD logs/O365 unified log for any "assign license" activities.

Highlighted

@Vasil Michev Is it not a bit easier? I'm doing the following but using the sharepoint online ID to get an overview of the E3 licences. I'm also trying to get when users could have switched from an E2 to E3 licence. 

 

$users = Get-AzureADUser -All:$True

$count = $users.count

 

$report = @()

 

$i = 0

foreach ($u in $users)

{

$i++; #Write-Host "$i of $count": $u.UserPrincipalName

 

$upn = $u.UserPrincipalName

$comp= $u.CompanyName

$state= $u.State

$licenses = $u | select -expand AssignedLicenses
foreach ($l in $licenses){
$license = ""
if ($l.skuId -eq "18181a46-0d4e-45cd-891e-60aabd171b4e"){$license = "E1"}
if ($l.skuId -eq "6634e0ce-1a9f-428c-a498-f84ec7b8aa2e"){$license = "E2"}
if ($l.skuId -eq "6fd2c87f-b296-42f0-b197-1e91e994b900"){$license = "E3"}
if ($l.skuId -eq "c7df2760-2c81-4ef7-b578-5b5392b571df"){$license = "E5"}
if ($license -ne ""){

$plans = $u | select -expand AssignedPlans
$firstdaySharePoint = ""
$firstdayhigherlicense = ""
foreach ($p in $plans){
if ($p.ServicePlanId -eq "e95bec33-7c88-4a70-8e19-b10bd9d0c014"){
$firstdaySharePoint = $p.AssignedTimestamp;
}
if ($p.ServicePlanId -eq "efb87545-963c-4e0d-99df-69c6916d9eb0" -and $p.CapabilityStatus -eq "Enabled"){
$firstdayhigherlicense = $p.AssignedTimestamp;
}

}
Write-Host $u.UserPrincipalName $license $firstdaySharePoint $firstdayhigherlicense
$report += New-Object psobject -Property @{UserPrincipalName = $u.UserPrincipalName; FirstOffice365License = $firstdaySharePoint; FirstHigherLicense = $firstdayhigherlicense; CompanyName = $u.CompanyName; State = $u.State; CurrentLicense = $license}

 

}

 

}
$report | select UserPrincipalName,CompanyName,State,FirstOffice365License,CurrentLicense | Export-CSV C:\temp\licences_$CurrentDate.csv –noType -Encoding:UTF8 -Delimiter ";"

Highlighted

This covers the individual service plans, not the license assignment as a whole, which I believe was the original ask. Those can have different values, and in general the license itself can be assigned/removed multiple times - the AAD cmdlets will only show you the latest timestamp.