Core.ProfilePictureUploader questions

Copper Contributor

I'm not a developer, but more of a System Admin that uses scripting languages. So please pardon me if the answer is obvious.


We have come across a situation that we need to upload User Profile Pictures to SharePoint Online, for users that doesn't have Exchange Online mailbox yet. So we have found this project on GITHUB:


We took the code and compiled it and it's able to bulk upload User Profile Pictures, but we ran into two issues. When I tried to submit an issue on GITHUB, it suggested me to use this community instead.


1. The executable file requires credential of SPO tenant admin (Office 365 admin), with our Security Requirement, all O365 admin must use second factor authentication, this has been causing the executable file to fail to authenticate as a service account, following error is recorded:

Initializing SPO web service https://<tenant>

Error initiating connection to profile web service in SPO The sign-in name or password does not match one in the Microsoft account system.

Processing finished for 0 user profiles (or so)


We would like to find what exact permission it requires for uploading the pictures, without having to use O365 admin credential, which is an obvious overkill. I've tried to comb through UnifiedAuditLog and found nothing.


2. There are scenarios that the on premise user account is disabled, as such we'll need to have a way to purge their user profile picture on SharePoint Online. I've tried to modify the CSV file from:






The log file generated following error:

7/10/2018 10:00:06 PM : Begin processing for user
7/10/2018 10:00:06 PM : Fetching source image:
7/10/2018 10:00:06 PM : User Error: Error fetching source image for URL Invalid URI: The URI is empty.
7/10/2018 10:00:06 PM : End processing for user


Since I'm not developer, I will need some detailed code snippet, and which section of the existing code to change to archive this function. 


You feedback is very much appreciated

1 Reply

In the code, I can see it's using Microsoft.SharePoint.Client.File.SaveBinaryDirect to upload Picture to SharePoint Online. Is there a function I can call to Remove a Profile Picture instead?


                    using (Stream mediumThumb = ResizeImageSmall(ProfilePicture, _mediumThumbWidth))
                        if (mediumThumb != null)
                            spImageUrl = string.Format(spPhotoPathTempate, PictureName, "M");
                            LogMessage("Uploading medium image to " + spImageUrl, LogLevel.Information);
                            Microsoft.SharePoint.Client.File.SaveBinaryDirect(mySiteclientContext, spImageUrl, mediumThumb, true);