none
Find Office 365 users that do not have a CERTAIN license RRS feed

  • Question

  • My objective is to search for users in Office 365 that do not have a certain license.

    Of course, there is this very simple option:

    Get-MsolUser -UnlicensedUsersOnly

    But that will display users that have no license at all.

    (and yes, I would be using PowerShell)

    I want to find users that would NOT have this license, for example:

    myorg:ENTERPRISEPACK_GOV

    Licenses in the properties of a MsolUser are displayed like this:

    Licenses     : {myorg:EMS, myorg:POWER_BI_STANDARD, myorg:ENTERPRISEPACK_GOV}

    So I tried this (but with no confidence it would actually work):

    Get-MsolUser -All | where { $_.Licenses -contains "ENTERPRISEPACK" }

    and

    Get-MsolUser -All | where { $_.Licenses -match "ENTERPRISEPACK" }

    No results.

    EDIT: of course, once I see the query works I would change the operator so it returns only those users that do NOT have the license.

    I think (?) the licenses are listed in a sort of array (right?) and I'm not sure how to set up the query in such a scenario.

    Does anyone know how I could achieve that?

    Thanks in advance!


    Please mark as helpful if you find my contribution useful or as an answer if it does answer your question. That will encourage me - and others - to take time out to help you.


    Thursday, September 5, 2019 5:37 PM

All replies

  • "Licenses" is not a property of an MsolUser object.


    \_(ツ)_/

    Thursday, September 5, 2019 8:06 PM
  • Get-MsolUser -all |  %{ $license= $_.licenses.Accountskuid -join ';'  ; $user = $_.DisplayName  if($license -like "*standard*") { Write-Host "-" } else { Write-Host $user }}

    Replaces standard with license you want it should  show you the list of users  without that license.


    S_K_P


    • Proposed as answer by S_K_P Thursday, September 5, 2019 11:37 PM
    • Edited by S_K_P Friday, September 6, 2019 9:36 PM
    Thursday, September 5, 2019 11:37 PM
  • I'm checking  to see if the reply above is helpful to you.

    S_K_P

    Monday, September 9, 2019 9:37 PM
  • Thanks guys, taking a look now.

    Please mark as helpful if you find my contribution useful or as an answer if it does answer your question. That will encourage me - and others - to take time out to help you.

    Wednesday, September 11, 2019 11:46 AM

  • Please mark as helpful if you find my contribution useful or as an answer if it does answer your question. That will encourage me - and others - to take time out to help you.

    Wednesday, September 11, 2019 11:59 AM
  • S_K_P: I tried your suggestion but encountered the error in the screenshot above.



    Please mark as helpful if you find my contribution useful or as an answer if it does answer your question. That will encourage me - and others - to take time out to help you.

    Wednesday, September 11, 2019 12:02 PM
  • Sorry the code was missing a ;.

    Please add a semicolon ; before if in the powershell command.

     Get-MsolUser -all |  %{ $license= $_.licenses.Accountskuid -join ';'  ; $user = $_.DisplayName ; if($license -like "*standard*") { Write-Host "-" } else { Write-Host $user }}


    S_K_P

    Wednesday, September 11, 2019 7:55 PM
  • S_K_P: that produces output but it is not clear, which has as much to do with the complexity of our licensing as anything else. Some users have the full Office 365 enterprise pack and others have the Exchange Online 2 plan. Among this last group, some are listed in the output of your script... and some are not.

    I have to concentrate on something else for a couple days so I'm going to mark your responses as helpful (because they are) and take another look at this later next week.


    Please mark as helpful if you find my contribution useful or as an answer if it does answer your question. That will encourage me - and others - to take time out to help you.

    Friday, September 13, 2019 11:55 AM
  • And once again, I am ultimately trying to verify that everyone has a licensed Exchange Online mailbox, regardless of what license ensures that and regardless of whatever other licenses they might have.

    EDIT: yes, the Exchange Online 2 plan licenses were purchased and assigned very recently and that factor was not part of my original post. 


    Please mark as helpful if you find my contribution useful or as an answer if it does answer your question. That will encourage me - and others - to take time out to help you.


    Friday, September 13, 2019 11:58 AM