Get list of specifc groups from specific users

Welcome Forums General PowerShell Q&A Get list of specifc groups from specific users

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
3 years, 4 months ago.

  • Author
    Posts
  • #29300

    Participant
    Points: 0
    Rank: Member

    I have users that I want to be able to enter in when prompted and see if they have membership in certain groups, (for example all the groups that have the prefix of HMM, like HMMHome, HMMStart, HMMServe...)

    I can use Get-ADPrincipalGroup to do it for a specific user, and I can use Get-ADGroup with a -filter {name -like "HMM*"

    but I can't seem to get what I want which is a combination of both of them?!?!

  • #29315

    Participant
    Points: 0
    Rank: Member

    What about just piping the results of Get-ADPrincipalGroupMembership to Where-Object to limit the results:

    Get-ADPrincipalGroupMembership username | Where-Object {$_.name -like "HMM*"}
    
  • #29323

    Participant
    Points: 0
    Rank: Member

    Yes, that's exactly what I needed, thnx!

The topic ‘Get list of specifc groups from specific users’ is closed to new replies.