microsoft-365-docs icon indicating copy to clipboard operation
microsoft-365-docs copied to clipboard

please provide an example to get all unlicensed synchronised users

Open anwarmahmood1 opened this issue 1 year ago • 1 comments

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.

anwarmahmood1 avatar Jul 27 '22 12:07 anwarmahmood1

@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 avatar Jul 29 '22 14:07 msbemba

@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.

yogkumgit avatar Aug 15 '22 05:08 yogkumgit