开发者

Add user to SharePoint 2010 group using powershell

开发者 https://www.devze.com 2023-01-10 22:19 出处:网络
We need to add severa开发者_如何学运维l users to several SharePoint Groups. Does anyone have an example of how to add a user to a sharepoint group using power shell.To add multiple users to multiple

We need to add severa开发者_如何学运维l users to several SharePoint Groups.

Does anyone have an example of how to add a user to a sharepoint group using power shell.


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"))
    )

#Call function without brackets
AddUsers $userArray "http://my-sharepoint-site/"


Try this PowerShell script:

Set-SPUser -Identity 'fun/factory' -Web http://someserver -Group 'Name of group'
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号