none
Copy Sharepoint User Profile properties from one account to another

    Question

  • We had one user that had some issues with his account such as losing his permissions etc.  After trying different fixes with no success we decided to create a completely new account for this user in Active Directory.  Any user profile attributes that are stored in AD are correct in this new account because we could just enter them in AD.  However, the old account had many other user profile attributes that were specific to SharePoint, for example the personal photo, some "About me" description, the "My Links" etc.  Is there some PowerShell command I can run to copy over all the Sharepoint user profile attributes from the old account to the new account?  Note that we do not want to do "Migrate User" since that would copy over other stuff as well such as permissions as since the old account had some permissions issues we do not want to copy that over.

    thanks,

    Monday, October 14, 2013 3:06 PM

Answers

  • Hi bbatl, 

    It's essentially the same. In the code example below, I'm getting the source and destination profiles by calling GetUserProfile(samAccount). Once you have each user profile, you can copy the values of each profile property like this:

    [void][reflection.assembly]::Loadwithpartialname("Microsoft.Office.Server") | out-null;                        
    $site=new-object Microsoft.SharePoint.SPSite("https://CentralAdminSite:443"); #Central Admin site                        
    $serviceContext = Get-SPServiceContext $site                     
    $site.Dispose();                        
    $upm = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext);                        
    $sourceprofile = $upm.GetUserProfile("domain\user1");
    $destinationprofile = $upm.GetUserProfile("domain\user2");
    $destinationprofile["AboutMe"].Value = $sourceprofile["AboutMe"];
    $destinationprofile.Commit();
    Hope that helps!


    Regards, Matthew
    MCPD | MCITP
    My Blog
    Please remember to click "Mark As Answer" if a post solves your problem or "Vote As Helpful" if it was useful.

    See my webpart on the TechNet Gallery that allows administrative users to upload, crop and format user profile photos. Check it out here: Upload and Crop User Profile Photos

    • Marked as answer by bbatl Tuesday, October 15, 2013 2:24 PM
    Tuesday, October 15, 2013 8:40 AM

All replies

  • I wrote a TechNet Wiki article about accessing user profile properties using PowerShell. You could use this to copy the profile properties between two different users profiles. 

    The article is here: http://social.technet.microsoft.com/wiki/contents/articles/18328.sharepoint-2010-viewing-sorting-and-filtering-sharepoint-user-profiles-using-powershell.aspx


    Regards, Matthew
    MCPD | MCITP
    My Blog
    Please remember to click "Mark As Answer" if a post solves your problem or "Vote As Helpful" if it was useful.

    See my webpart on the TechNet Gallery that allows administrative users to upload, crop and format user profile photos. Check it out here: Upload and Crop User Profile Photos

    Monday, October 14, 2013 3:19 PM
  • Matthew,

    Your article only addresses the "list all profiles" cases.  I need to case for first finding a profile by account name and then updating another profile with these values.  Your scripts did not have any write operations.  I tried to edit your script to retrieve a profile by account name but it's not working for me.  Do you have an example of how to:

    - retrieve all attributes of a given profile (accessing the profile by either username or last and first name)

    - updating all the attributes of the new profile with the values retrieved in step 1.

    thanks,

    Monday, October 14, 2013 10:47 PM
  • Hi bbatl, 

    It's essentially the same. In the code example below, I'm getting the source and destination profiles by calling GetUserProfile(samAccount). Once you have each user profile, you can copy the values of each profile property like this:

    [void][reflection.assembly]::Loadwithpartialname("Microsoft.Office.Server") | out-null;                        
    $site=new-object Microsoft.SharePoint.SPSite("https://CentralAdminSite:443"); #Central Admin site                        
    $serviceContext = Get-SPServiceContext $site                     
    $site.Dispose();                        
    $upm = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext);                        
    $sourceprofile = $upm.GetUserProfile("domain\user1");
    $destinationprofile = $upm.GetUserProfile("domain\user2");
    $destinationprofile["AboutMe"].Value = $sourceprofile["AboutMe"];
    $destinationprofile.Commit();
    Hope that helps!


    Regards, Matthew
    MCPD | MCITP
    My Blog
    Please remember to click "Mark As Answer" if a post solves your problem or "Vote As Helpful" if it was useful.

    See my webpart on the TechNet Gallery that allows administrative users to upload, crop and format user profile photos. Check it out here: Upload and Crop User Profile Photos

    • Marked as answer by bbatl Tuesday, October 15, 2013 2:24 PM
    Tuesday, October 15, 2013 8:40 AM
  • Thank you so much!
    Tuesday, October 15, 2013 2:23 PM