Forum Discussion
Microsoft 365 E3 User Check
- Apr 02, 2020
Well you are basically filtering all the users that do have the license, so everyone else is skipped. If you want to list the users that do not have the license, adjust the statement in the where clause to -notmatch. If you want both licensed and unlicensed, remove the clause altogether and simply populate the IsLicensed value accordingly:
Get-content c:\temp\users.txt | foreach { Get-MsolUser -UserPrincipalName $_ } | Select-Object UserPrincipalname,@{n="islicensed";e={(&{if ($_.Licenses.AccountSkuId -match "tenant:ENTERPRISEPACK") {"True"} else {"False"}})}}| Export-csv c:\temp\E3.csv
where I've complicated things a bit by doing everything in-line, but hopefully you get the idea. Make sure you enter the correct SKUid.
Thanks for the reply VasilMichev For some reason running the example you gave me and adjusting the SKUid exports a .csv and all users have the Islicensed column populated False. I then made a users.txt file with half of the list known F1 users and half known E3 users and the .csv output comes back with all users showing False in the Islicensed column. Any ideas what might be happening? And thanks again for your help!
Hard to tell without specific examples, but then again I didn't spend much time testing the example 🙂