SharePoint Automation Gary Lapointe – Founding Partner, Aptillon, Inc.

Comments (82) Trackbacks (0)
  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! :D

  2. Mine too

    thanks for this – and the update urls in stps from other servers – you really are a hero!

  3. 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?

  4. also can pictures be in folders to do this?

  5. 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

  6. 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.

  7. 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…

  8. 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.

  9. 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.

  10. 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
    Point.STSADM.Commands.wsp

    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.

  11. 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.

  12. 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?

  13. 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.

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

  15. 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?

  16. 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.

  17. 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?

    Thanks

    Denis Chicoine

  18. Denis – try again with the latest release. I’ve since added some error handling that will hopefully address the issue you are having.

  19. 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?

    Michael

  20. 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.

  21. 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
    77b-c4cd21e642af)

  22. You need to have an EmployeeID property added to the profile – this property doesn’t exist by default.

  23. 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?

  24. Ok I was able to run it I had some syntax issue. But now the image urls are like this :
    http://intranet.mactec.com/Directory/EmployeePhotos/$(EmployeeID).jpg instead of EmployeeID being replaced.

  25. The variable name is case sensitive – you need to have it all lowercase.

  26. 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.

  27. 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.

  28. 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?

  29. This command won’t do a straight up search and replace but you could easily tweak the code to do what you want.

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

  31. 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”.

  32. 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.

  33. Hi Gary,
    This command is awesome!. Thanks for sharing your tools with the world. I am your newest fan!

  34. 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??

    Thanks
    Martin

  35. You’d need to pull the source down and add support for this property, recompile and deploy.

  36. 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 ?

  37. 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?

    regars
    Robban

  38. 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
    Robert

  39. It’s probably due to the loopback fix – see my post for the gl-setbackconnectionhostnames command.

  40. Hi again…

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

    kind regards
    Robert

  41. Not sure. Just omit the -validate parameter.

  42. 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.

    br
    Robert

  43. 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?

    Thanks

  44. Make sure the profile sync jobs are running. You can run “stsadm -o sync” to force it to run.

  45. 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.

  46. 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
    Robert

  47. 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!
    BR
    Robert

  48. 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

    Thanks,
    Naresh

  49. Nick said…
    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 ?

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

  50. 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

  51. 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.

  52. 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,

  53. 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).

  54. You can’t do it through designer – you need to be a farm admin and install it on the server (the install instructions are on the downloads page).

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

  56. 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.

  57. 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.
    Zdenka

  58. Zdenka – who’s Mike? :)

    You can dump the output of any command by simply piping it to a file:

    stsadm -o … > log.txt

  59. Hi Gary,
    oh, I’m terribly sorry to call you Mike. I had hard day…
    It works!

    Have a nice day.
    Kind Regards
    Zdenka

  60. No worries – just giving you a hard time :)

  61. 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.

  62. 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\”

  63. Will these scripts work on Sharepoint 2010 as well or only on 2007?

  64. They will not work with 2010. I have plans to migrate to 2010 but just haven’t had time.

  65. 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!

  66. Are you getting any errors when compiling? Do you have the correct version for your SharePoint environment (2007 or 2010)?

  67. very nice tool.
    Is there any option to see how many users get affected.

  68. 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.

    • 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.

  69. 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

  70. 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

    Reagards
    Ashok. M

  71. 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.

  72. A good write up to do this with powershell can be found here. The entire script is provided. It will allow you to import pictures and then set and resize them in the SharePoint User Profile store.
    http://licomputersource.com/Blog/2010/12/uploading-user-profile-pictures-programmatically/

  73. [...] Set User Profile Picture URL Property using STSADM (revisited) « SharePoint Automation [...]

  74. 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?


Leave a comment

CAPTCHA Image

*

No trackbacks yet.