Created
December 11, 2019 17:41
-
-
Save nicolonsky/421a0179cda201d9bf3f0c34a275ca94 to your computer and use it in GitHub Desktop.
Get all Office 365, Azure users with license assignment errors [requires msonline module]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$licenseAssignmentErrors = Get-MsolGroup -HasLicenseErrorsOnly $true | % { | |
$groupId = $_.ObjectId | |
Get-MsolGroupMember -All -GroupObjectId $groupId | | |
Get-MsolUser -ObjectId {$_.ObjectId} | | |
Where {$_.IndirectLicenseErrors -and $_.IndirectLicenseErrors.ReferencedObjectId -eq $groupId} | | |
Select ObjectId, ` | |
DisplayName, ` | |
@{Name="LicenseError";Expression={$_.IndirectLicenseErrors | Where {$_.ReferencedObjectId -eq $groupId} | Select -ExpandProperty Error} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment