none
Check user exists in a SharePoint group using Powershell RRS feed

  • Question

  • Hi All,

    Is it possible to check if a user exists in a SharePoint group using powershell?

    I am trying to validate the user using $_. (pipelining) but nothing works out.

    Any suggestions would be greatly appreciated.


    Cheers! Maruthu | http://sharepoint-works.blogspot.com

    Thursday, January 3, 2013 2:06 PM

Answers

  • You could try something like:

    $groups = $web.SiteGroups
    $User = $groups["Group"].Users | where {$_.UserLogin -eq "User"}
    


    • Marked as answer by Maruthachalam Friday, January 4, 2013 8:40 AM
    Thursday, January 3, 2013 2:32 PM
  • Or something like this... ;-)

    $w = get-spweb http://my
    $gs = $w.SiteGroups
    $g = $gs[12]
    $user = $g.Users.GetByEmail("user@domain.com")
    if($user -eq $null){write-host "User Not Found"}


    Regards, Matthew
    MCPD | MCITP
    My Blog
    Please remember to click "Mark As Answer" if a post solves your problem or "Vote As Helpful" if it was useful.

    • Marked as answer by Maruthachalam Friday, January 4, 2013 8:40 AM
    Thursday, January 3, 2013 2:36 PM

All replies

  • You could try something like:

    $groups = $web.SiteGroups
    $User = $groups["Group"].Users | where {$_.UserLogin -eq "User"}
    


    • Marked as answer by Maruthachalam Friday, January 4, 2013 8:40 AM
    Thursday, January 3, 2013 2:32 PM
  • Or something like this... ;-)

    $w = get-spweb http://my
    $gs = $w.SiteGroups
    $g = $gs[12]
    $user = $g.Users.GetByEmail("user@domain.com")
    if($user -eq $null){write-host "User Not Found"}


    Regards, Matthew
    MCPD | MCITP
    My Blog
    Please remember to click "Mark As Answer" if a post solves your problem or "Vote As Helpful" if it was useful.

    • Marked as answer by Maruthachalam Friday, January 4, 2013 8:40 AM
    Thursday, January 3, 2013 2:36 PM