Bulk Upload and Update User Profile Photos in SharePoint 2013.

Bulk upload of profile pictures for SharePoint 2013. The script do not require property mapping and do not rewrites the PictureURL. Supports BMP, GIF, JPEG, PNG, TIFF, and WMF picture formats.Paths to the photos can be local or network.

 
 
 
 
 
4.8 Star
(24)
3,741 times
Add to favorites
SharePoint
4/6/2017
E-mail Twitter del.icio.us Digg Facebook
  • Hello and Help please
    1 Posts | Last post March 08, 2018
    • I used your PS script to upload 1000+ new user profile images to our mysites. We have just combined with another business and had to import photos for all of their employees. In this regard, it was successful, thanks very much.
      
      Where I need help is, the original photo import task scheduled job, now does not pick up pics for new hires. These new hires do exist in Edit User Profile, just with no photos. Any idea how I might get it pointed back at the correct original photo source so it will need to keep auto creating with SP task scheduled?
      
      Thank You
  • Profile Pictures are uploading but not going to users
    2 Posts | Last post July 05, 2017
    • Hi,
      I was able to run the script, the pictures uploaded but the pictures are not going/pointing to the user profiles. Thoughts? No error on the script. 
      Thanks!
    • I have the same problem. The pictures are uploaded to the library but not visible in the user profile.
  • Non thing happen
    1 Posts | Last post March 20, 2017
    • Hello,
      
      When I run the code the is no error message. But nothing happen in my sp. Not only I don't have  pictures updated but there are not going to the user profiles.
      I'm using SP 2016 on premise with windows 2012 R2. I hope some one could help me.
      Thanks 
  • Upload-ToUserPhotos bug
    3 Posts | Last post December 02, 2016
    • Hi! In the function upload photo should be that string <$spFile = $folder.Files.Add($web.ServerRelativeUrl + "/" + "User%20Photos" + "/" + $folder.Url + "/" + "0c37852b-34d0-418e-91c6-2ac25af4be5b_" + $ID + ".jpg", [System.IO.Stream]$fileStream, $true)>,
      I have added $web.ServerRelativeUrl, because My Site Host can be deployed as a Subsite of a site collection and path of file in SharePoint Folder (Add method in SPFolder) required be as ServerRelativeUrl. Please, fix your script.
      Cheers. 
    • I just wanted to post and say that @Maxim Kitsenko is exactly right. The script wasn't working for me until I made the change he specified to line 127 (within the "Upload-ToUserPhotos" function) as he recommended.
      
      This is probably going to happen to ANYone who uses the script when their mysite URL is not the root web of the web application.
      Thanks again Maxim!
    • I forgot to mention, this script seems to work just fine on SharePoint 2016 (provided you make the change Maxim recommends).
      
      Thanks again Ivan and Maxim.
  • Upload/Update Error
    11 Posts | Last post May 09, 2016
    • Hi 
      
      when we run the update script we get a error "Exception calling "Add" with 3 arguments value does not fall within expected range
      
      Any suggestions what we have missed?
    • Hi Phill,
      
      Make sure that you have library "User Photos" in you My Site host and there is a folder called "Profile Pictures". If there is no such library/folder you can create it by manually uploading a picture for some account. 
    • Hi Ivan
      
      I have looked and we have those folders as most users already have a photo, we are trying to fill in the blanks
    • Hi Phill,
      
      Do you have Id column filled in the CSV.
      Have you filled the full path to the pictures.
      The account that is running the scipt should have write permission in the script execution directory, since it is used as temp location.
      Do you get any other errors?
    • yes the csv looks like
      RecordID,LoginName,PhotoPath
      123,dc1\testuser,c:\photo\testuser.jpg 
    • Hi Phill,
      
      Something in the ulpoad function is not right. Can you fill the photo path with only one user that has no profile picture
    • Hi Ivan, I have tried debugging the script and I now get another error regarding the ProfilePropertyCache does not have a6783c01-6c90-4540-9101-fa8e2d13355b
    • Hi Ivan, I have now fixed this with permissions, but I am still getting the add error
    • Hi Phill,
      
      Maybe you should receive more meaningful error if you do not have permissions to upload. But can you test if you are able to upload files in the picture library. 
      The mechanism of uploading the photo is simple, get the folder from the root web of the My sites host, form the URL from the library relative url,folder url, and upload the file stream of the temporary picture under name "0c37852b-34d0-418e-91c6-2ac25af4be5b_" + $ID + ".jpg" 
    • By the way is your CSV saved as simple CSV after you fill the paths? You can do some debugging by outputting the elements that are needed for the upload and see if everything is correct like folder url and ID check function Upload-ToUserPhotos
    • Had the same issue, but as advised below, I didn't have site collection admin permissions. Now it works!
  • Unable to upload the picture for account: "user"
    4 Posts | Last post September 09, 2015
    • Ivan,
      
      I'm in SharePoint 2013, I have a new mysite web app created for our users.  The new site has the root template created, the User Photos folder and the Profile Pictures created and working.  When I go into an individual user profile and upload the pic it works great.  But I can't do this for 1,200 users.
      
      Running from my SP-Admin farm account, the script works fine to generate the CSV.  I've filled in the path column and when running the updatephotos switch I get an error for all users, "unable to upload the picture for account:"DOMAIN\CurrentUser", folowing exception occurred: Cannot find path 'C:\spscripts\convertedPicture.jpg" because it does not exist.  Exception calling "FromFile" ... etc
      
      My path I've filled in for the CSV file is "C:\Photos".  So the creation of the JPG seems to be the culprit here.
      
      I must be missing something obvious here?
      
      Thanks for any input you might have.
      
      Greg
    • Hi Greg,
      
      The scrip is making a copy of the picture in the execution path of the script with name tempPicture.jpg. Then it checks what is the original file extension and convert it to .jpg, uploads it with appropriate name and deletes it. Are you able to copy files to the script execution directory, in your case C:\spscripts? Note that the script cannot automatically match usernames to profile pictures, this is why you fill the csv with the literal path of every users picture like "C:\Photos\JohnSmith.png".
    • Ivan,
      
      Your clarification to point to the actual jpg file made all the difference.  So sorry to bother you.  The rest is history, all valid login account pics uploaded and thumbnails created in their user profiles.  Fantastic stuff!
      
      Thanks a bunch,
      Greg
    • Hi Greg,
      
      Glad you find the script useful, your feedback is important!
      
      Thanks,
      Ivan
  • All I get is "Unable to get the picture for Account..."
    3 Posts | Last post March 11, 2015
    • My photos are stored in a SharePoint library which has Read Only access open to all users.  I updated the CSV file to reference the following URL, for example:
      
      3,Domain\User,https://www.portalsite.com/library/file.jpg
      
      If I paste that same URL into IE on the server, the photo appears fine.  But when I run the script, it errors out with each user and says unable to get the picture.  What could be the issue?
    • Hi,
      
      The script cannot download the pictures from the Internet Url.
      
      It works only with pictures that are on file system (Local/Internet).
      
      As workaround I can suggest you to try to sync the SharePoint library where your pictures are located with OneDrive and use them.
      
      Or you can try to modify the script to downloading the pictures when the protocol is http/https.
      
      This is a good idea and I may modify the script in future, but I cannot tell you when I will be able to do so.
      
      Best Regards,
      Ivan
    • keep it up
  • Getting error Unable to upload the picture for account :
    14 Posts | Last post March 11, 2015
    • Hi 
      I am able to generate csv but when I am running powershell script to upload the image I am getting error Unable to upload picture for account
    • Hello,
      
      Please make sure that User Photos library exist in your My Sites Host site.
      
      And also that there is a folder called "Profile Pictures".
      
      If you are running the script in a clean installation there is a big chance that the folder is missing. You can create it manually or upload manually a profile pic for some account and the folder will be created.
    • Hi,
      
      I have the same problem. My folder is not called "Profile Pictures" but with the german name "Profilbilder". What do I have to change to get your script running?
    • Hi,
      
      Please, try to find the function Upload-ToUserPhotos.
      There are two variables. In original script they are:
          $docLibraryName = "User Photos" 
          $docLibraryUrlName = "Profile%20Pictures" 
      
      Firs one is the Library name and second is the folder name. Note that the folder name is encoded(space = %20), edit this according to your environment and try again.
    • Also edit this line (the url construction there is "User%20Photos")
          $spFile = $folder.Files.Add("/" + "User%20Photos" + "/" + $folder.Url + "/" + "0c37852b-34d0-418e-91c6-2ac25af4be5b_" + $ID + ".jpg", [System.IO.Stream]$fileStream, $true)
      
      Let me know if this worked out.
      
      BR,
      Ivan
    • I changed the $docLibraryUrlName variable but it still doesn't work. What do I have to change in the $spFile line?
    • I just remove the try/catch to get better error messages. It look like that's a permission problem:
      
      Upload-ToUserPhotos : Exception calling "Add" with "3" argument(s): "<nativehr>0x80070005</nativehr><nativestack></nativestack>Access denied."
      At C:\temp\Upload-ProfilePhotos.ps1:147 char:6
      +                     Upload-ToUserPhotos -ID $acc.RecordID -Path ($PSScriptRoot + "\tempPicture. ...
      +    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : NotSpecified: (:) [Upload-ToUserPhotos], MethodInvocationException
          + FullyQualifiedErrorId : UnauthorizedAccessException,Upload-ToUserPhotos
      
      The user running the script has full control to the user profile service. Any idea how to fix the problem?
    • Maybe it is permissions over the MySite Host sitecollection
    • Yes, I added the user as site collection administrator and now it works. Thanks a lot Ivan for this script and your help.
    • Great! Your feedback matters for further improvement :)
    • Theres a typo in the parameter and function name. It says GererateCSV instead of GenerateCSV.
      
      Maybe you could add a check for the permissions and tell the user if he doesn't have the permission to upload the photo.
    • Thank you for the help!
      
      It seems that I am very consist in replicating typos :D
      
      I updated the script and uploaded v1.1. The typo is fixed, error handling will show you the exact message. Support quoted picture file path(easier to copy paths in 2012).
      
      Please, if it is possible test v1.1. For me it was working fine.
      
      BR,
      Ivan
    • Works perfect, thanks
    • No doubt. Great work