none
Check if user exists in SharePoint group using powershell RRS feed

  • Question

  • Hi,

    I am adding the users to the SharePoint group as below

    $user = $web.Site.RootWeb.EnsureUser($username)

    $ownerGroup = $web.SiteGroups["groupname"]

    $ownerGroup.AddUser($user)

    But i want to test if user is already available in group.

    If user is available,want to display the message as user already exists.

    But may i not the possibilities of checking if user is available in the SharePoint group.

    Please provide your inputs on the same.

    Regards,

    Sudheer


    Thanks & Regards, Sudheer

    Friday, October 16, 2015 6:57 AM

Answers

  • Hi,

    Removed a line to check if user exists because

    Even if I am not checking if user present in the group,

    It is adding if user doesn't exist,but of course it is not adding the user multiple times in the group.

    Regards,

    Sudheer


    Thanks & Regards, Sudheer


    Tuesday, October 27, 2015 6:00 AM

All replies