Forum Discussion

charlie4872's avatar
charlie4872
Brass Contributor
Apr 02, 2020
Solved

Microsoft 365 E3 User Check

Hello I am trying to adjust a script I have that checks if a user is licensed for E3 in Microsoft 365. The script I have below works by checking a list of users and seeing which ones are licensed for...
  • VasilMichev's avatar
    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.

Resources