none
Display specific groups using get-adprimcipalgroupmembership RRS feed

  • Question

  • Hi All,

    I am working on a script to help my dev id whether a user is a member a specific group.  So far, I have been working with 

    Get-ADPrincipalGroupMembership $env:UserName | Select-Object -Property Name| Sort-Object -Property Name

    and that returns EVERY group (which is annoying for me since I apparently live in like 14 groups, and only 3 I didn't know of).  I am trying to filter out the list so that only group test3 shows up, but my attempts at filtering aren't working.  I was thinking of using the $_.where name -eq 'test3' but that didn't work.  Any ideas on how to specify just the group name I'm looking for?

    Thanks!


    Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.


    • Edited by Obujuwami Thursday, May 25, 2017 10:08 PM
    Thursday, May 25, 2017 10:05 PM

Answers

  • So I ended up getting the answer from my coder who looked at the script and said it looked like I needed some command in linux, then I did a google search for that and powershell, which lead me to Slect-String.  That got me what I was looking for.  THanks for answering!

    Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    • Marked as answer by Obujuwami Wednesday, May 31, 2017 11:00 PM
    Wednesday, May 31, 2017 11:00 PM

All replies

  • I was thinking of using the $_.where name -eq 'test3' but that didn't work.

    Can you be more specific about your exact syntax and what "that didn't work" means?


    -- Bill Stewart [Bill_Stewart]

    Thursday, May 25, 2017 10:16 PM
    Moderator
  • So I ended up getting the answer from my coder who looked at the script and said it looked like I needed some command in linux, then I did a google search for that and powershell, which lead me to Slect-String.  That got me what I was looking for.  THanks for answering!

    Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    • Marked as answer by Obujuwami Wednesday, May 31, 2017 11:00 PM
    Wednesday, May 31, 2017 11:00 PM