Bulk load users in a group


All replies

  • 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:

    Kind Regards, Justin Nash

    Tuesday, March 13, 2012 10: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:

    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.


    Thomas Balkeståhl - Technical Specialist - SharePoint -
    Download the SharePoint Branding Project here

    Tuesday, March 13, 2012 11:07 PM
  • Hello!

    Following the link


    2.$SPSite = New-Object Microsoft.SharePoint.SPSite("http://wss"); $OpenWeb = $SpSite.

    3. $User | ForEach-Object {

    But I get the error

    Missing ')' in method call.
    At line:4 char:15
    +         $_.test <<<< @sss.yyy,
        + CategoryInfo          : ParserError: (CloseParenToken:TokenId) [], Paren
        + FullyQualifiedErrorId : MissingEndParenthesisInMethodCall

    Please advice
    Wednesday, March 14, 2012 2:28 PM
  • Hi

    I tried it and it works for me. Perhaps just a copy-paste-error? Try this (replace with your site and groupname)


    $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 12:07 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()


    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
        + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell

    Please advice

    Friday, March 16, 2012 4:15 PM
  • I think I got it!
    Friday, March 16, 2012 4:25 PM
  • Hello!

    Cannot get the following script working:

    $User | ForEach-Object{$TheNewGroup.AddUser($_.test,$,$_.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 <<<<,$_.test LastName,"")}
        + CategoryInfo          : ParserError: (CloseParenToken:TokenId) [], Parse
        + FullyQualifiedErrorId : MissingEndParenthesisInMethodCall

    Friday, March 16, 2012 7:33 PM
  • Hi.

    If you are trying to add the string '' to the $_.test then I think that you need to do it better.

    $User | ForEach-Object{$TheNewGroup.AddUser($_.test,$_.test + "",$_.test lastname,"")}


    $User | ForEach-Object{
    $email = $_.test+"";
    $TheNewGroup.AddUser($_.test,$email,$_.test lastname,"")


    Thomas Balkeståhl - Technical Specialist - SharePoint -
    Download the SharePoint Branding Project here

    Friday, March 16, 2012 8:42 PM