SarePoint Powershell Add user to Group
$FromGroupnames = "001总经理","010101管理本部" $ToGroupname = "test" $SPWeb = Get-SPWeb -Identity http://192.168.0.50:81/ $groups = $SPWeb.SiteGroups $count = 0 foreach ($group1 in $groups ) { foreach ($group2 in $FromGroupnames) { if($group1.name -eq $group2) { foreach ($user in $group1.users) { Set-SPUser $user -Web $SPWeb -Group $ToGroupname Write-Host $ToGroupname.name "adding: " $user.name; $count++ } } } } Write-Host "complete!user count ="$count