Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a backup of a 2007 site which has been upgraded and added as the root site collection in a new web application. I am currently migrating content from this site collection to another site collection within the same web application (separate content databases).

I need to migrate the Users list (/_catalogs/users/simple.aspx) to the new site. Is there an easy way of migrating these users (such as using the OOB Migration API), or something as simple as iterating over each user, and running an EnsureUser on them in the new site?

share|improve this question
1  
Did the user permissions not come over when you moved the site collections, etc.? –  John Chapman Sep 13 '11 at 21:31
    
Here's the scenario: Restore a 2007 content DB, run the upgrade, and import it into a temporary site collection. At this point, I have a successful upgrade including all users. Now what I need to do (while migrating other things such as other libraries), is migrate the user accounts along with it. –  Tim Gabrhel Sep 14 '11 at 13:41
add comment

1 Answer

up vote 1 down vote accepted

Here's a PowerShell Script that should do it. You need to supply the source and destination URLs and a group name to put the users into, at least temporarily.

$spWebDestination = Get-SpWeb -Identity http://destination.local
$spWebSource = Get-SpWeb -Identity http://source.local

$users = $spWebSource.SiteUsers
$destinationGroup = $spWebDestination.Groups["Temporary Group"]

"Source Group count = " + $users.Count 
"Destination Group count = " + $destinationGroup.Users.Count

foreach($user in $users)
{
    "Adding User " + $user.Name + " to " + $spWebDestination.Url
    $destinationGroup.AddUser($user)
}

"New Destination Group count = " + $destinationGroup.Users.Count
share|improve this answer
    
Interesting concept. So by adding these users into the temporary group, does this add them to the hidden users list? As if they have logged in? I can't fully explain the requirement for needing them. It's just the requirement I was given for a separate app to work. –  Tim Gabrhel Sep 14 '11 at 13:42
    
@tim Yes. Adding the users to the group will add them to the site collection's User Information List. –  Tom Resing Sep 14 '11 at 23:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.