A little over a year ago I created one of my first STSADM commands, gl-setpictureurlnewpath, which I developed in order to enable me to set the picture URL property for user profile objects to a new path as the result of the upgrade which resulted in the images going to a new library. This time I needed to do set the property but there was no existing data so the existing command I had wouldn't work as is. I considered reworking the command to accommodate both scenarios but in the end decided to just leave the existing one alone and create a new command which I called gl-setpictureurl.
Updating a user profile object through code is actually really simple - you just get an instance of the UserProfileManager object and then either loop through the items in the collection or use the GetUserProfile method to retrieve a specific UserProfile object. Once you have the object you can edit any of the properties using simple indexer notation (userProfile["PictureURL"].Value = url). Once you've updated the appropriate properties you call the Commit() method on the user profile object.
The help for the command is shown below:
C:\>stsadm -help gl-setpictureurl stsadm -o gl-setpictureurl Sets the picture URL path for user profiles. The following variables may be used for dynamic replacement: "$(username)" , "$(domain)", "$(email)", "$(firstname)", "$(lastname)", "$(employeeid)". Parameters: -path <path to new photo (i.e., "http://intranet/hr/EmployeePictures/$(username).jpg") - leave blank to clear> [-sspname <name of the SSP>] [-username <DOMAIN\name>] [-overwrite] [-ignoremissingdata] [-validateurl]
The following table summarizes the command and its various parameters:
|Command Name||Availability||Build Date|
|gl-setpictureurl||MOSS 2007||Released: 9/18/2008
|Parameter Name||Short Form||Required||Description||Example Usage|
|path||p||Yes||The path to the images. To substitute dynamic data use the following strings variables within the path: $(username), $(domain), $(email), $(firstname), $(lastname), $(employeeid). The variable names are case sensitive.||-path "http://intranet/hr/EmployeePictures/$(username).jpg"
|sspname||ssp||No||The name of the SSP. If not specified then the default SSP will be used.||-sspname SSP1
|username||u||No||The account name associated with the specific user profile to update. If omitted then all user profiles will be updated.||-username "domain\user"
|overwrite||ow||No||If provided then existing data values will be overwritten. If omitted then any profile objects with existing data will be ignored.||-overwrite
|ignoremissingdata||ignore||No||If specified then do not error if a specified variable value cannot be found. Note that if the value is not found then the property value will not be set.||-ignoremissingdata
|validateurl||validate||No||If specified then perform a web request to see if the resultant URL is valid. If the result is not valid then the property value will be set to an empty string.||-validaturl
The following is an example of how to set the picture URL property of all user profiles:
stsadm -o gl-setpictureurl -path "http://intranet/hr/EmployeePictures/$(username).jpg" -overwrite
Updated 4/17/2009: The command has been updated to include the employeeid variable as well as the ignoremissingdata and the validateurl parameters. Thanks to Tim Griepp for providing some code that I used to motivate myself to look at this command again :)