Bulk load users in a group
-
Tuesday, March 13, 2012 9:30 PMHow do I bulk load users to a group on a specific site?
All Replies
-
Tuesday, March 13, 2012 10:07 PM
Hi ChitraSaha,
Usually you will have groups already defined in AD and have included them using SharePoint's User Profile synchronization Service. It helps if you are targeting multiple groups to have them added to one group for easier maintenance.
For more information see: http://blogs.msdn.com/b/spsocial/archive/2010/05/04/conceptual-view-of-how-user-profile-synchronization-works-in-sharepoint-2010.aspx
Kind Regards, Justin Nash
-
Tuesday, March 13, 2012 11:07 PM
Hi ChitraSaha.
What you preferably do is add all the users to a AD group, then add that AD group to a SharePoint group. That way, you can administer the users access in AD and SharePoint.
But, if this is not an option, then you could use Powershell to add all the users. My good friend Niklas Goude tells you how:
http://www.powershell.nu/2009/01/06/adding-user-to-group-in-sharepoint/Configure it to read all users from a csv file or xml file and it will work. Remember though, there is a limitation on the number of users a SharePoint group can hold...better to use AD.
Regards
Thomas Balkeståhl - Technical Specialist - SharePoint - http://blog.blksthl.com
Download the SharePoint Branding Project here- Proposed As Answer by Jason Li - Canada Saturday, March 17, 2012 6:49 AM
- Marked As Answer by Emir LiuMicrosoft Contingent Staff, Moderator Friday, March 23, 2012 2:49 AM
-
Wednesday, March 14, 2012 2:28 PMHello!
Following the link
http://www.powershell.nu/2009/01/06/adding-user-to-group-in-sharepoint/
1[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
2.$SPSite = New-Object Microsoft.SharePoint.SPSite("http://wss"); $OpenWeb = $SpSite.
3. $User | ForEach-Object {
$TheNewGroup.AddUser(
$_.test,
$_.test@sss.yyy,
$_.test,
""
)
}
But I get the error
Missing ')' in method call.
At line:4 char:15
+ $_.test <<<< @sss.yyy,
+ CategoryInfo : ParserError: (CloseParenToken:TokenId) [], Paren
tContainsErrorRecordException
+ FullyQualifiedErrorId : MissingEndParenthesisInMethodCall
Please advice -
Friday, March 16, 2012 12:07 PM
Hi
I tried it and it works for me. Perhaps just a copy-paste-error? Try this (replace with your site and groupname)
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$SPSite = New-Object Microsoft.SharePoint.SPSite("http://mysharepointsite"); $OpenWeb = $SpSite.OpenWeb(); $TheNewGroup = $OpenWeb.SiteGroups | Where-Object {$_.Name -match "myGroupName"}; $OpenWeb.Dispose(); $SPSite.Dispose()
$SPSite = New-Object Microsoft.SharePoint.SPSite("http://mysharepointsite"); $OpenWeb = $SpSite.OpenWeb(); $User = $OpenWeb.Users | Select Name, Email, LoginName; $OpenWeb.Dispose(); $SPSite.Dispose()
$User | ForEach-Object {$TheNewGroup.AddUser($_.LoginName,$_.Email,$_.Name,"")} -
Friday, March 16, 2012 4:15 PM
After executing the following statement:
$SPSite = New-Object Microsoft.SharePoint.SPSite("http://test"); $OpenWeb = $SpSite.OpenWeb(); $User = $OpenWeb.Users | Select Name, Email, LoginName; $OpenWeb.Dispose(); $SPSite.Dispose()
Error
New-Object : A positional parameter cannot be found that accepts argument 'Stud
ent Life'.
At line:1 char:21
+ $SPSite = New-Object <<<< Microsoft.SharePoint.SPSite("http://test")$OpenWeb = $SpSite.OpenWeb(); $User = $OpenWeb.Users | Select Name, Emai
l, LoginName; $OpenWeb.Dispose(); $SPSite.Dispose()
+ CategoryInfo : InvalidArgument: (:) [New-Object], ParameterBind
ingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell
.Commands.NewObjectCommand
Please advice
-
Friday, March 16, 2012 4:25 PMI think I got it!
-
Friday, March 16, 2012 7:33 PM
Hello!
Cannot get the following script working:
$User | ForEach-Object{$TheNewGroup.AddUser($_.test,$_.test@sss.xxx,$_.test lastname,"")}
PS C:\Scripts> .\user.ps1
Missing ')' in method call.
At C:\Scripts\user.ps1:1 char:58
+ $User | ForEach-Object{$TheNewGroup.AddUser($_.test,$_.test <<<< @sss.xxx,$_.test LastName,"")}
+ CategoryInfo : ParserError: (CloseParenToken:TokenId) [], Parse
Exception
+ FullyQualifiedErrorId : MissingEndParenthesisInMethodCall -
Friday, March 16, 2012 8:42 PM
Hi.
If you are trying to add the string '@sss.xxx' to the $_.test then I think that you need to do it better.
Try:$User | ForEach-Object{$TheNewGroup.AddUser($_.test,$_.test + "@sss.xxx",$_.test lastname,"")}
Or:
$User | ForEach-Object{
$email = $_.test+"@sss.xxx";
$TheNewGroup.AddUser($_.test,$email,$_.test lastname,"")
}Regards
Thomas Balkeståhl - Technical Specialist - SharePoint - http://blog.blksthl.com
Download the SharePoint Branding Project here

