locked
Results comparison in powershell RRS feed

  • Question

  • I have list of users in O365 group, lets name it O365Group (1). And I would like to do some cleaning with it. I found users without license in O365 (2) , but I can't compare it (3) with users from O365Group - I'd like to find any users in O365Group  with has't licenses

    (1) get-azureadgroupmember  -ObjectId yrc234a6-2876da7-9re7-2fk69c7e2018 -all 1 | sort-object displayname

    (2) Get-MsolUser -All | where {$_.isLicensed -eq $true}

    (3) Get-MsolUser -All |  Where {$_.IsLicensed -eq $false } 
        foreach ($User in  $_.UserPrincipalName)
              {
                get-azureadgroupmember  -ObjectId yrc234a6-2876da7-9re7-2fk69c7e2018 -all 1 |
                     where {$_.UserPrincipalName -like "$_.UserPrincipalName"} |
                         sort-object displayname
         }


    Wednesday, July 11, 2018 1:04 PM

All replies

  • I'm having a hard time understanding what you're saying.

    I think you're asking how to find unlicensed members of a group called "O365Group". In this case, I would compare in the opposite way you're doing. it.

    $Group = Get-MsolGroup -SearchString <yourgroupname>
    
    $Membership = Get-MsolGroupMember -GroupObjectId $Group.ObjectId
    
    foreach ($member in $membership) {Get-MsolUser -ObjectId $member.objectid | Where-Object islicensed -ne $true}



    Mike Crowley

    My Blog | MikeCrowley.US

    Baseline Technologies | Baseline.Consulting

    Being ignorant is not so much a shame, as being unwilling to learn

    -Ben Franklin

    • Proposed as answer by Mike Crowley Saturday, December 22, 2018 5:44 AM
    Saturday, December 22, 2018 5:44 AM