Friday, 28 September 2007

Using stsadm to add users to a SharePoint group

At first glance, the stsadm adduser command seems a bit of a pain when adding users into SharePoint because you have to specify a userlogin, useremail and username variable when using the command - these are not optional.

However, I have found that when I use dummy names for the useremail and username variables, the user profile database in MOSS overwrites them once the user has been added to the group. So, I used the following stsadm command to add users to a SharePoint group, which can be useful when you have bulk users to add from a CSV file:

stsadm -o adduser -url http:// -userlogin -useremail test@test.com -group "" -username "Test User"

For example,

stsadm -o adduser -url https://portal.edulink.internal -userlogin EDULINK\phil.childs -useremail test@test.com -group "Corporate Users" -username "Test User"

Once added, wait a few seconds and the e-mail address and user name changes from test@test.com and Test User to the correct one specified in the user profile database. Make sure that you test this with one user first though, before creating a script to add 1000 users all at once!

9 comments: