@lalajee, Thanks or posting in Q&A. Based on my testing, to query the user who has Microsoft Intune license assigned, you can run the following PowerShell commands and enter Global administrator account to query the information:
install-module MSOnline
import-module MSOnline
Connect-MsolService
$Users = Get-MsolUser -All
Write-Host "The user who has Intune license assigned"
foreach ($User in $Users)
{
$ServiceStatus = $user.licenses.ServiceStatus
$ProvisionName = $ServiceStatus | Where {$_.ServicePlan.ServiceName -eq "INTUNE_A" }
$Data = [PSCustomObject]@{
"USER" = $User.UserPrincipalName
"Software" = $ProvisionName.ServicePlan.ServiceName
"Status" = $ProvisionName.ProvisioningStatus
}
if($Data.Status -eq "Success" -or $Data.Status -eq "PendingInput")
{
Write-Host $Data.USER+ $Data.Software
}
}
Hope the above information can help.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.