.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Upload Profile Picture using PowerShell

Posted By:      Posted Date: October 11, 2010    Points: 0   Category :SharePoint


We have 2 requirement

First, to update the each profile picture programmatically with powershell. We are able to update the picture property of a profile,

Second, we need to create a picture library in their User profile and upload the picture from the document library(Which has a list of image of Employee) and set that path to the profile picture url.

we are not able to create the document library in the User profile. Its throwing error message as "Access Deined". Through Object Model we are able to achieved it throught SPSecurity.RunWithElevatedPriliveige. But throught PowerShell we dont know how to achieve this.

Please Suggest how to achieve this.

Note: We are Using SharePoint 2007 Server.


Ganesh Moorthy S

View Complete Post

More Related Resource Links

Programmatically Upload Pictures to SharePoint Profile Picture Store using Powershell


I'm trying to create a powershell script that will bulk upload pictures to the SharePoint Profile Picture Store located in a "http://sp2010/my/User Photos/Profile Pictures".  I found Chris Johnson's blog post ( http://blogs.msdn.com/b/cjohnson/archive/2010/05/08/sharepoint-2010-office-2010-and-profile-pictures.aspx )  extremely useful.  However, the SPUtils.ps1 that is referenced on his site doesn't seem to support uploading to the "Profile Pictures" folder within the "User Photos" picture library at "http://sp2010/my/User Photos".  My account has full control of the "User Photos" picture library and the "Profile Pictures" folder, and I can upload to the "User Photos", root directory with no problems.  The file fails to upload to the "Profile Pictures" folder.

Currently my Powershell script processes a folder of pictures.  First, it pulls the file name and does some manipulations to retrieve the employee number of the employee.  Second, it performs an active directory search to get the employee's user name.  Third, it resizes the photo to match the small, medium, and large thumbnails generated by a traditional manual upload of a photo from the user's edit profile page.  After each creation of the resized picture it uploads the picture t

Extended MySite: Profile picture uploading to the wrong zone.

I'm experiencing a problem where uploading a profile picture, in a MySite, uploads it to the wrong zone.

What I've done is created one web application and configured SSP to use that same one. As a result, the MySite host location is in that same web application:

Default Zone:
http://my.domain.com  <-- default SharePoint site.
http://my.domain.com/personal <-- MySite host

I then extended that web application to enable FBA & anonymous access:

Internet Zone:
http://extended.domain.com <-- extended default SharePoint site.

Now I"m able to navigate to a user's MySite using the extended URL (http://extended.domain.com/personal)...but when I upload a new profile picture in my MySite... it prompts me for new credentials because it's trying to upload to the Default zone (http://my.domain.com).

I found the following thread that talks about this...but there wasn't any resolution:

What is the best practices when configuring a MySite in an extended web application? How can I fix the situation I'm encountering above?

P.S. I tried to change the MySite Host location (via SSP in the Central Administration)

BDC Import for user profile picture

I am attempting to populate the user profile property 'Picture' with data from a BDC connection. My column from the BDC contains urls but SharePoint will not allow me to map Picture to the column. I"m guessing this is because the property is expecting a strongly typed Url type. That doesn't help me though. So, has anyone successfully mapped the Picture property to a field from a BDC connection. (-SN: I know the field can be mapped to AD but I need it mapped to a BDC) Thanks in advance.

Configure Synchronization connections with PowerShell (User Profile)

Hi, I was checking the Pshell cmdlets for SPS2010 and wasn't able to configure the sync connection after creating the User Profile SA. Do you know if it's possible to configure this part (AD, filters, etc) in PShell ? Is it done using the "SetupSynchronizationService" method of the User Profile Service Application object ? Thanks ! Wes  

Can Not Comment On images stored in the picture libraray(created in profile location )

Hi, I have created a picture library in the profile location (under the location where person.aspx is available) I want to achieve social comment on the images stored under profile location I am displaying it on a page using object model Can any one please help me....

Sharepoint 2010: Editing My Profile:Choose Picture gives errors

Hi, I've got the User Profile Service Application up and running.  When I try to add my picture to my Profile by clicking on the Choose Picture button, it gives an error.  Any ideas?   Thanks.

User Profile Sync - Profile Picture Export to AD Problem

To start, I think I've read every post/blog/etc there is on this subject.  Currently I have user profile import to Sharepoint 2010 working.  It imports profile data just fine.  Everything in the FIM Synchronization manager show success even.  Its the export from Sharepoint to AD of the user profile picture that isn't working at all.  I've gone thru the steps of adding the thumbnailphoto export under the picture properties.  I can see the export inside of the FIM manager.  I notice though that in FIM there is there a DS_EXPORT of the objects.  I've looked into the SyncDB and noticed in the metaverse table the SPS_MV_OctetString_PictureURL never gets updated with the information from the PictureURL column of the ProfileDB.  It is always Null.  Actually in FIM it only shows one person with an update, and keep showing the PictureURL property as being not applied, which is probably because it is showing it as blank only.  In the connector for the object in FIM, I get the error that I've seen in some blog posts where it says PictureURL (String) is not compatible with SPS_MV_OctetString_PicutreURL (binary), but that seems to be how Sharepoint builds the connection even though FIM finds it invalid.  I've had that created, deleted several times, so I guess that is ordinary, and not sure that is even the problem.

Problem in "Upload a picture into data base" because is in

Hi guys. I can upload a picture into database by this code correctly in a web page without "UpdatePanel": ******************************** SqlConnection connection = null; try { Byte[] imgByte = null; if (FileUpload.HasFile && FileUpload.PostedFile != null) { HttpPostedFile File = FileUpload.PostedFile; imgByte = new Byte[File.ContentLength]; File.InputStream.Read(imgByte, 0, File.ContentLength); } // Insert the employee name and image into db string conn = "Data Source=PC5;Initial Catalog=LaptopStore;Integrated Security=True"; connection = new SqlConnection(conn); connection.Open(); string sql = "INSERT INTO test(image) VALUES(@image) SELECT @@IDENTITY"; SqlCommand cmd = new SqlCommand(sql, connection); cmd.Parameters.AddWithValue("@image", imgByte); int id = Convert.ToInt32(cmd.ExecuteScalar()); lblResult.Text = String.Format("Employee ID is {0}", id); } catch { lblResult.Text = "There was an error"; } finally { connection.Close(); } ******************************************** But when I want to use this code in a

Programmatically Uploading User Profile Pictures using Powershell

I've reviewed other solutions for this, but I need clarification on something I'm not getting by reading other posts.  I'm using a powershell script to: 1)  Upload profile pictures on our network into the User Photos picture library in the My Site Host.  This works. 2) Associate a picture to a user profile.  I'm using this command ... $up.get_Item($picturePropertyName).Value = $PortraitUrl ... where $up is the user profile, $picturePropertyName is the property name of the url (PictureUrl), and $PortraitUrl is the full path to the picture uploaded in point 1 above.  This isn't working. 3) Eventually I will be executing the Update-SPProfileStore command to automatically resize the images once they've been added. Clarification required ... when I associate a picture to the user profile in step 2 above, is this what will automatically generate the 3 thumbnails for me (in the Profile Picture folder)?  Or ... do I have to manually create the 3 images?  Or ... will it associate the image I've provided and then the Update-SPProfileStore command will create the 3 resized images for me? I notice that when I associate a picture to a profile using the 'Edit my Profile' UI, it automatically creates the thumbnails for me.  I'm just not understanding how these pieces fit together.  I see some code snippets out there for r

How to edit a profile picture path

Hello! I'm wondering how to edit the default profile picture path in SharePoint 2010 , to point to a picture library that contains files with usernames as filenames.   Like: administrator.jpg in a picture library called "User Tiles"   I'm really desperate for an answer. please help.   /RomanRoman Alifanov(1989)- MCTS-MCAD-MCP-MCT - IT Hero - www.animaonline.blogspot.com

upload images to a picture library from infopath form



   I am having an infopath form, from where i need to upload images to picture library . 

User Profile Sync - Picture to thumbnailphoto export


Hi there,

I'm trying to get the staff pictures from My Sites to update the thumbnailphoto attribute in Active Directory.

I've setup the User Profile Sync, and I'm able to import and export to AD. However, I'm having a problem getting the Picture property to update the thumbnailphoto attribute. I can't find any errors, and it looks as though the sync is working to some extent because any previous information in thumbnailphoto is cleared after a sync.

If I look at what's going on in Forefront Identity Manager for 'DS_EXPORT', i can see that it has deleted the old value, and that the new value is empty.

Any suggestions are greatly appreciated!



how to import user Profile Picture already stored in AD as thumbnailphoto or jpegphoto


We already store out photos in AD using both the thumbnailsphoto and jpegphoto properties. Outlook2010 shows the user profile correctly. Now we want to sync sharepoint 2010 with AD and retreive the photo. I currenrlt have it setup as mentioned in this MSDN post to Export.


Is it odd that the thumbnailphoto and jpeg photo have been in AD since at least 2007( I think they were even in 2003 schema) but that this user profile syncing to those two atributes isn't the default behavour? Outlook 2010 used those photos instantly, yet sharepoint can't out of the box?


I've opened a Case with MS about this. I'll post findings here.

**Edit 2**

Also the previous method used in Moss 2007 doesn't work wither. Setting the URL to the photo in an AD ExtensionAttribute1 and having sharepoint import it.

how to validate picture library to upload only image files?



how to validate "Picture library" to upload only image files. Currently now it is accepting .doc,.txt files etc.

Is there any way to overcome this issue?




Creating User Profile Service application and proxy using PowerShell

Hi All,

Not sure if anybody have tried creating a new user profile service application and user profile service aplication proxy using PowerShell?

I am able to create the user profile service application using the following cmdlet:

-ApplicationPool "SharePoint Web Services Default"
-Name "Demo Profile User Service"
-MySiteHostLocation http://demo2010a:80/my
-ProfileDBName UserProfile_ProfileDB_Demo
-ProfileSyncDBName UserProfile_SyncDB_Demo
-SocialDBName UserProfile_SocialDB_SyncDB

I was also not able to supply the MySite Host Relative Path (-MySiteRelativePath) and MySites have not been set up for the user profile application. And again, get-help lists MySiteRelativePath as a valid parameter, but when executed, PowerShell throws that the parameter is invalid. 

I am unable to create  a new proxy for the above created user profile service application using the cmdlet:


The cmdlet keeps asking for parameter Uri which seems to be undocumented.

Would be glad if anyone can help out here.

SharePoint Developer - MCTS SharePoin

Exporting SharePoint profile picture to ActiveDirectory thumbnailPhoto attribute problem!



I am trying to export SharePoint profile Picture to ActiveDirectory thumbnailPhoto attribute.  Here's what I did so far :

  • FIM account has Replicating Directory Changes, Read and Write permissions on the users OU
  • Central Administration -> Manage service applications -> User Profile Service Application -> Manage User Properties -> Picture -> Edit -> Add New Mapping -> AD - thumbnailPhoto - export
  • Start Profile Synchronization
  • Result :

Stage SharePoint Server export
Additions 0
Updates 0
Unchanged 0
Successes 0
Failures 0

I have then found on the Internet that since My Sites are in https, I have to load the root certificate in SharePoint.  I use a "GeoTrust DV SSL CA" for My Sites so I have downloaded the GeoTrust_Global_CA.cer root certificate from GeoTrust and did the following :

  • Central Administration -> Security -> Manage Trust -> New -> GeoTrust - GeoTrust_Global_CA.cer
  • Result :

The Root Certificate that was just selected is inv

Uploading a profile picture in sharepoint 2010 through visual studio



  Is it possible to upload a profile picture in sharepoint2010(mysite) through visual studio(C#) ?'

   If so Could you please share the code.

thanks in advance,




ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend