microsoft-365-docs
microsoft-365-docs copied to clipboard
please provide an example to get all unlicensed synchronised users
This benefits your readers who are migrating from 'msonline' to Microsoft Graph.
With 'msonline', the command is...
Get-MsolUser -UnlicensedUsersOnly -Synchronized -all
The Microsoft Graph equivalent appears to be
Get-MgUser -Filter 'assignedLicenses/$count eq 0 and OnPremisesSyncEnabled eq true' -ConsistencyLevel eventual -CountVariable unlicensedUserCount -All
You may also wish to notify people equivalent command is slower - in my case, about 5 times slower - than the 'msonline' equivalent. As fair warning.
By using '-select UserPrincipalName', the query is much, much faster;
Get-MgUser -Filter 'assignedLicenses/$count eq 0 and OnPremisesSyncEnabled eq true' -ConsistencyLevel eventual -CountVariable unlicensedUserCount -All -Select UserPrincipalName
These examples will really help people migrating from the 'msonline' module.
[Enter feedback here]
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 073b885d-191e-8c00-fa59-ad83ba79ec10
- Version Independent ID: 4bd5799d-9baf-90b6-634d-398fbea6b66f
- Content: Assign Microsoft 365 licenses to user accounts with PowerShell - Microsoft 365 Enterprise
- Content Source: microsoft-365/enterprise/assign-licenses-to-user-accounts-with-microsoft-365-powershell.md
- Service: o365-administration
- GitHub Login: @kelleyvice-msft
- Microsoft Alias: kvice
@anwarmahmood1 Thank you for your feedback. We have made changes to the document via PR#https://github.com/MicrosoftDocs/microsoft-365-docs/pull/9285
Once the author approves, the changes will be live.
Thanks Sri
@msbemba Thank you very much for the contribution and updating the documentation with PR. @anwarmahmood1 Hope this update is helpful for you. Thanks for taking out some time to open the issue. Appreciate and encourage you to do the same in future also.