We need to add several users to several SharePoint Groups.
Does anyone have an example of how to add a user to a sharepoint group using power shell.
We need to add several users to several SharePoint Groups.
Does anyone have an example of how to add a user to a sharepoint group using power shell.
Hi
Try this script Set-SPUser -Identity 'fun/factory' -Web http://someserver -Group 'Name of group'
To add multiple users to multiple groups, you could use a longer script:
Function AddUsers($userArray, $webUrl)
{
foreach ($user in $userArray)
{
$username = $user[0];
foreach ($group in $user[1])
{
Set-SPUser -Identity $username -Web $webUrl -Group $group
}
}
}
$userArray = @(
@("domain\user1", @("Site Visitors", "Designers")),
@("domain\user2", @("Site Visitors", "Designers")),
@("domain\user3", @("Site Owners"))
)
AddUsers($userArray, "http://my-sharepoint-site/")