Skip to content

Instantly share code, notes, and snippets.

@nicolonsky
Created December 11, 2019 17:41
Show Gist options
  • Save nicolonsky/421a0179cda201d9bf3f0c34a275ca94 to your computer and use it in GitHub Desktop.
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]
$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