Here is the scenario.

  1. I have a development farm.
  2. I copied all the pictures from production mysite to dev mysite so now all the pictures are in the mysite:8000/employees/User Photos/ Library.

Is there a powershell command I can run to update user profiles for picture url?


  • I see this script Update-SPProfilePictures "my-sites-host-url" "User Photos" "C:\Photos-Path\" "Your_Domain" but it assumes pictures are in the file share. In my case. all the pictures in the "user photos" library. Oct 23, 2013 at 15:08

2 Answers 2


Try the below powershell code to update picture for a given user,


$siteurl = "http://<MySiteHost URL>/"

$site = New-Object Microsoft.SharePoint.SPSite($siteurl)
$context = [Microsoft.Office.Server.ServerContext]::GetContext($site)

#This gets the User Profile Manager which is what we want to get hold of the users
$upm = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
$groups = $site.RootWeb.sitegroups

foreach ($grp in $groups) 
foreach ($user in $grp.users) 
"User: " + $user.name
if ($upm.UserExists($user))
$profile = $upm.GetUserProfile($user)
$profile["PictureURL"].Value = "<MySiteHostURL>/User%20Photos/Profile%20Pictures/user.jpg";


Hope this helps you.

  • This wont work. I seen this before. The problem is that I have 5000 users and this script only takes care of 1 user. Oct 24, 2013 at 12:35
  • Now I have altered the code, it will fetch and iterate all the users from all the available SharePoint group in your site collection and change the picture. Oct 24, 2013 at 12:45
  • hmm. I am not sure why i need to do this at group level. you know when you go to user profile from central admin and there is picure. That's the picture I need to update. say, when you add a new picture for someone it gets added the my site photo library. how could i do this for the users who dont have picture in the profile but pics are present in the photo library of the mysite. Oct 25, 2013 at 18:27
  • I am going to do it this way but need little help if possible. I am going to add for each foreach ($userProfile in $profiles) { if($userProfile["PictureUrl"].Value -qe $null) {$userprofile["PictureURL"].Value = url} I need to built a string mysite:8000/employees/user photos/domain_username.jpg. Problem is AccountName gives you domain/username. I think I need a regex to turn that / into _. Oct 25, 2013 at 20:20
  • you may also have to issue the following command afterwards Update-SPProfilePhotoStore -MySiteHostLocation $mySiteUrl to create the thumbnails used throughout the site.
    – Mauro
    Dec 24, 2014 at 18:14

If I understand correctly, you have my sites in dev that have been copied from production. The profiles that have pictures have URLs that point to production. You have also copied the actual pictures from production to the User Photos library in the dev my site host.

If this is correct, I can tell you what I did in this situation.

Others have mentioned Update-SPProfilePhotoStore and that is what I used.

From TechNet:

During the migration of profile photos from one server URL to another, one can use the OldBaseUri and NewBaseUri parameters. You just need to specify the starting portion of the URL that has changed from old to new and an attempt to rebase the profile picture URLs will occur. For example, OldBaseUri: http://server1/my/ProfilePhotos; NewBaseUri: http://server1/my/NewLocation/ProfilePhotos

Just make sure that all the pictures exist in the new location before running it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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