none
Bulk load users in a group

Risposte

Tutte le risposte

  • 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

    martedì 13 marzo 2012 22:07
  • 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

    martedì 13 marzo 2012 23:07
  • Hello!

    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
    mercoledì 14 marzo 2012 14:28
  • 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,"")}

    venerdì 16 marzo 2012 12:07
  • 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

    venerdì 16 marzo 2012 16:15
  • I think I got it!
    venerdì 16 marzo 2012 16:25
  • 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

    venerdì 16 marzo 2012 19:33
  • 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

    venerdì 16 marzo 2012 20:42