Admins can audit the assigned licenses to users along with the assignment path i.e whether group based or direct assignment via licenses blade in azure active directory.
The list obtained by the above method cannot be exported and it is a limitation. To exports the results, admins should need PowerShell script. One is mentioned below,
function Users-LicenseType
{
Param(
[System.Management.Automation.PSCredential]$cred
)
Connect-MsolService -Credential $cred
$Gplist= @{}
$Group =Get-msolgroup
# Get all groupname with group objectId
foreach($gp in $Group)
{
$Gplist+=@{$gp.ObjectId.ToString() = $gp.DisplayName}
}
$users= Get-MsolUser -All
$AllUser = @()
# Find Users License Type
foreach($user in $users)
{
$UserList = "" | Select "UserPrincipalName","LicenseType"
$lic=$user.Licenses.GroupsAssigningLicense.Guid
if($lic -ne $null)
{
$GpName = ''
foreach($lc in $lic)
{
If($GpName) {
if($Gplist.Item($lc.ToString()) -ne $null)
{
$GpName=$GpName + ";" + $Gplist.Item($lc.ToString())
}
}
Else {
if($Gplist.Item($lc.ToString()) -ne $null)
{
$GpName=$Gplist.Item($lc.ToString())
}
}
}
$UserList.UserPrincipalName = $user.UserPrincipalName
$UserList.LicenseType = "Inherited("+$GpName+")"
$AllUser+= $UserList
$UserList =$null
}
Else
{
$UserList.UserPrincipalName = $user.UserPrincipalName
$UserList.LicenseType = "Direct"
$AllUser+= $UserList
$UserList =$null
}
}
$cred =Get-Credential
$Listofusers = Users-LicenseType -cred $cred
$Listofusers
}
To Run,
PS C:\PowershellQuery> & '.\all-users-with-license-type.ps1
Comments
0 comments
Please sign in to leave a comment.