Aug 05 2019
02:11 AM
- last edited on
Feb 07 2023
07:08 PM
by
TechCommunityAP
Aug 05 2019
02:11 AM
- last edited on
Feb 07 2023
07:08 PM
by
TechCommunityAP
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.
Aug 05 2019 06:00 AM
Aug 05 2019 10:22 AM
That, or you can crawl the Azure AD logs/O365 unified log for any "assign license" activities.
Aug 05 2019 01:57 PM
@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 ";"
Aug 05 2019 11:25 PM
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.