82 thoughts on “Set User Profile Picture URL Property using STSADM (revisited)

  1. Thanks very much! I needed this one, as our staff photos are located in an external application (phone system) but are saved as (username).jpg. You are my new Sharepoint hero! 😀

  2. I have pictures of employees that are in the format of (LastName, FirstName).jpg. I take it I have to rename all these to be the user Network ID, or is there something else I can do?

  3. You wouldn’t have to rename – you could just do something like this:

    stsadm -o gl-setpictureurl -path “http://intranet/hr/EmployeePictures/($(lastname), $(firstname)).jpg” -overwrite

  4. You can put the pictures anywhere you want – as long as they can be accessed via an http link and you can construct a repeatable URL to them given the variables available.

  5. Very nice! This was almost exactly what I was looking for…

    Would it be possible to change so the program checks if the picture exists in the share before updating the URL?

    Only about 50% of our 5000 users have a photo at the moment…

  6. I ran the installation commands and all reported “operation completed succesfully” – but I do not see the gl- commands when I run stsadm. I ran the install in my dev environment first, and everything worked with no issues. This is the first solution I have deployed. Suggestions on where I might start looking to resolve this. The commands work well in dev but I need them in Prod.

  7. Make sure you ran the addsolution and deploysolution commands. Check Central Admin (Solution Management) and verify that it deployed with no errors. Check your event log for errors. Check that the dll is in the GAC and the xml file is in the config folder (change the WSP file extension to CAB and open it up and you’ll see the files I’m referring to). Try to deploy again using -force.

  8. I did try to re-run the commands. i do see where it says to use the -force command. i’ll check the items you listed and re-run with the -force. Thank you

    C:…AdminTool>”C:\Program Files\..\12\BIN\stsadm.exe” -o addsolution -filename Lapointe.Share

    A solution with the same name “lapointe.sharepoint.stsadm.commands.wsp” or id “
    2625fbe6-4884-4666-a1ae-6b06f0db8a6f” already exists in the solution store.
    Lapointe.SharePoint.STSADM.Commands.wsp: The Solution installation failed.

    C:…AdminTool>”C:\Program Files\..\12\BIN\stsadm.exe” -o deploysolution -name Lapointe.ShareP
    oint.STSADM.Commands.wsp -immediate -allowgacdeployment

    The solution “lapointe.sharepoint.stsadm.commands.wsp” has already been deployed
    . Use the force parameter to redeploy the solution.

    C:…AdminTool>”C:\Program Files\..\12\BIN\stsadm.exe” -o execadmsvcjobs

    Executing .
    Operation completed successfully.

  9. I ran the installation commands and all reported “operation completed succesfully” – but I do not see the gl- commands when I run stsadm. I ran the install in my dev environment first, and everything worked with no issues. This is the first solution I have deployed. Suggestions on where I might start looking to resolve this. The commands work well in dev but I need them in Prod.

  10. success – I ran the install from the search server, not the main front end server. Everything was installed and working on the main front end server, just not on the server I ran the install from. i manually placed the files on the search server and now the commands appear when I run stsadm. Is this expected behavior?

  11. As long as you are not using the “-local” switch on the deploy (so use -immediate) then the commands should be available on all servers. If not then there’s something going on with your timer service.

  12. This is a great post. Just need to a way to set the picture URL back to the default SharePoint settings.

  13. I’ve used the set picture command with success, but for some reason a couple of users still have their old picture displayed. I think (but I’m not entirely sure) the users which have set / changed their own picture in the past didn’t get updated with the new URL. I want to force the profile pictures and not allow the user to set any picture of him or herself. Any idea on why the update shouldn’t succeed for some users? A sync / SharedServices issue?

  14. You can check if it got updated by checking the properties in the profile management pages. You can also prevent users from being able to update their pictures by editing the property settings. You might have to run “stsadm -o sync” to get the profile pictures to sync to all site collections.

  15. Hello,

    This tool is really helpfull. I’m trying to update all my profiles. When the picture exist I want it to update the profile and when there’s no picture, I want it to continue down list of profiles without updating the url. I’m using the switch validateurl but when it reach a unreachable destination, the script stop there witout completing the remaining profiles. Am I doing something wrong or do I miss an argument?


    Denis Chicoine

  16. Hi, thank you for your post and hard work. If I have users without a picture and they will upload via there mysite a picture, in which path the pictures will be uploaded? In the “new one (you command)” or in the standard-path (shared pictures..)? If “standard path” how can I change this?


  17. If users are uploading their own pictures they will go to their shared library on their mysite. My command is mostly just useful if you are not allowing your users to do this. If you want to allow this then you might want to add an event receiver to their site which can capture the image being saved and then rename it or move it to a central library and then update the profile with the new path.

  18. Thanks for this tool. I am currently getting this error can you tell me how to fix it.
    Unable to determine Employee ID from existing profile data (00a6ac39-6618-4167-9

  19. Thank you for your quick response. I already have a employee ID filed setup that is mapped to AD.
    Is this EmployeeID case sensitive?
    Is there anything else that I may have done wrong?

  20. in sharepoint the name is EmployeeID and display name Employee ID. If I do not match the case I cannot run the command. I am not able to change the case for the property name.

    Can it be a new property with a new name? Or is there any work around. Thanks so mcuh for your help.

  21. You misunderstand – the variable name is case sensitive – I’m doing a simple search and replace so what you pass in via the command line must be lowercase – the code uses EmployeeID to get the managed property.

  22. I only want to rename part of the url. We moved the mysites to a different web application. We need to rename the first part of the url.

    From http:\\portalsite\username\image.jpg

    to http:\\mysites\username\image.jpg

    Can your tool accomplish this?

  23. We already have employeeID in the profile with uppercase “ID” that’s mapped to AD. How would we work around this case sesitivity issue?

  24. There is a difference between a variable and a managed field – what you are passing in is a variable that is replaced with the value of the managed field. The variable must be lowercase, the managed field must be “EmployeeID”.

  25. So, with the static managed field of “EmployeeID”, the only choice I have is to recompile your source code with case change, or to create a script that will enumerate all users with their respectable employeeID, and use your gl-setpictureurl to individually set their picture URL.

  26. Hi, I stored mit JPEG´s named like the Account ID Guid is. But $(ADGuid) (Display Name: Active Directory Id) doesn´t work…

    Any idea to use the AD ID??


  27. Hello,

    these info is helpful. BUT, in my peoplesearch results page I still do not see the images that belong to the userprofile ? Once in the userprofile the image IS shown ?

  28. Hi

    Love this command but it has suddenly stopped working…

    Now I keep getting an error:
    Validating URL “http://intranet/Profile Pictures/magnus.andersson@emain.se.jpg” for “DOMAIN\magand”.
    Exception occured validating URL “http://intranet/Profile Pictures/magnus.andersson@email.se.jpg” (property not updated):
    The remote server returned an error: (401) Unauthorized.

    any ide anybody?


  29. Hi

    I have been running gl-setpictureurl for some time now and its been wonderful. However it just stoped working. The Command I use is:
    stsadm -o gl-setpictureurl -path “http://intranet/Profile Pictures/$(email).jpg” -overwrite -ignore -validate

    But now Im getting an 401 error, like this: Exception occured validating URL “http://intranet/Profile Pictures/test1@domain.com.jpg” (property not updated) – The remote server returned an error: (401) Unauthorized.

    No configuration changes have been made exept updates from Microsoft.
    Any idea why this is happening now?

    best regards

  30. Hi again…

    I tried setting DisableLoopbackCheck to 1 and rebooted but it did not help… any more idea?

    kind regards

  31. That worked, however that will sett all profiles to have a pic with its email addess. And the profiles that dont have a picture will then have a red X as its picture. Not the “anonymous” pic. So it helped but it also made a little mess.


  32. Hi,
    The script works great. I have different issue hopefully someone here will be able to help.

    The photo shows up fine on Profile and MySite but on team site some pictures show up on Contact Webpart and some does not. When I go the profile the photo is there but nevers shows up on team site. Again some photo does show and some does not. Any idea what could cause this and way to fix it?


  33. Robert – Make sure that the user account you were running the command as has access to view the pictures from the server. If you get the same 401 error then troubleshoot from there.

  34. Thanks Gary

    If I go directly from a IE-browser to the picture it prompts for login. I then type the user that I am logged on as and it shows me the picture. Also the user that run the command. I tried open CMD with a specified user, the one I always used and with full MOSS and Windows rights. But 401 comes back. I am a little loss… but I can understand and see it’s a permission problem some how…
    I search on… 🙂

    best regards

  35. Hi again

    Problem solved…
    There was a stored password on the machine that was wrong. The command used that everytime, why I dont know. So I cleared the users in the Stored User Names and Passwords control panel applet, (Control keymgr.dll) and then it worked! Thanks again for you help and a great app!

  36. Hi,
    great tool,
    some gotchas, if you want to clear the reference run
    stsadm -o -gl-setpictureurl -path “”
    if you want to keep the noimage if the image doesnot exist in the library run the above command to reset first and then run
    stsadm -o gl-setpictureurl -path “path” -ignoremissingdata -overwrite


  37. Nick said…

    these info is helpful. BUT, in my peoplesearch results page I still do not see the images that belong to the userprofile ? Once in the userprofile the image IS shown ?

    That’s because you have to run an incremental or full crawl to get the changes in your indexes.

  38. Hi Gary,

    I really couldn’t thank you enough for this immensely useful piece you’ve put together. It works like charm and also extends customization in Sharepoint to a whole new level!

    Great work!!!

    Larry XL-IT

  39. Hi.. Can anybody tell me.. What is the method name which method, have been used in sharepoint 2010, while uploading the user profile photo to “User Photos” gallery..

    I tried using .NET reflector tool, to see the method. But couldnt find the exact method. Please help me.

  40. Hi – I’ve just started using sharepoint and I am currently working with Sharepoint Designer 2007. This may seem silly, but where do I add the command?
    Basically, can you show me step by step where to add the command?
    Thanks a lot,

  41. Great utility. I think the exception that happens with the “validat” option is because the code needs to handle a System.Net.WebException, rather than check for a 404 return code. At least that would be the issue with the source as posted on today’s date (which I borrowed, thanks).

  42. Gary – First you SP Podcast interview was great 2 weeks back. Are you planning on updating the SetPictureURL command for SharePoint 2010?

  43. Thanks! I will eventually migrate this one – I honestly just haven’t had the time (life keeps getting in the way :)). Hopefully I’ll be able to get to it this summer.

  44. Hi Mike
    I like to use your great command extension. As I am updating 1500 user profiles, I need to know who were not updated or errors. Is there any possibility to save the command results to a log?
    Thank you for your response.

  45. Sir,
    I need a small help with Sharepoint. I am new user to sharepoint and I was to automate the upload of files into the Sharepoint from my computer. I can use Batch Files or VB Scripts. Please let me know whether it is possible to automate the uploading of files into the Sharepoint.

  46. I would recommend using powershell to upload files in bulk. There’s several ways to do it – one easy way is to use webdav:

    Copy-Item “c:\myfilestoupload\*.*” “\\mysites.hostheader.name\mylibrary\”

  47. I have downloaded the source code and cannot get it to compile. I have also downloaded the wsp template and added the ‘gl-setpictureurl’ code to the template. And I cannot get that to compile either. Can you help me by telling me what I am doing wrong? Thanks!

  48. I want to display my images path like http://sitename/country/username.jpg
    But I am unable to get Country.

    Country is imported from AD to userprofile. But while running with stsadm it is not recongnising country it is taking like $(Country) only.

    I run command like stsadm -o gl-setpictureurl -path “http://sitename/$(country)/$(username).jpg”

    Please help how to get country name.

    1. The variables are hard coded in the source. In other words, I did not account for every possible AD variable, just a few that I knew I’d need. If you need others youc an download the source, adjust it, and redeploy.

  49. Hi,

    I have 35000 users, I am trying to set picture url for all users.
    In middle it saying unable to connect to remote server.
    I have already run gl-setbackconnectionhostnames, but ever in middle it saying unable to connect remote server after some time again it is working fine.

    When it saying unable to connect remote the users picture urls are not get effected.

    Please help

      1. Hi Thanks for the reply

        I have one issues which is not related to this tool.
        Please help me

        When I am imprting country from AD to user profile it showing country code EX: Denmark showing like DE

        How should I get contry name instead of country code?

        Please help

  50. Hi this tutorial helped me alot.

    But one small thing I think it is related to security issues.
    I have 3 different sites with different ports. For these 3 I have created a common site to place my pictures. And I have given read permissions to all users.This URL is set in my SSP for picture url.

    When I am trying to see these peoples from People search from one of my 3 sties it is again asking for Login.

    How to avoid this. Or is there any other way to place all pictures some where else?

    Please help me

    Ashok. M

    1. You can try adding each to your local intranet zone in IE. Not sure why you’re using different ports though – easier to just use host headers and keep them all on port 80.

  51. Hi,
    I want to explain my problem more details

    I have site A, Site B and site C. in Site C Ihave placed uers pictures and dynamically using your code I have changed picture url to http://Site C/username.jpg Till here good excellent working fine.

    Now I am performing people search from Site A or Site B then it is asking again for loging becasue we are using images url from Site C. But in site C I have given read permissions for all users.

    How to overcome this.

  52. Am not getting exact solution.I have to retrieve the picture from picture gallery or default image has been display in the sharepoint site.

    Can anyone explain for this question?

Comments are closed.