1

I need to batch update the profile picture of a large amount of users on my domain. I intend to do this using a spreadsheet containing the links to the pictures and the user's email address.

I've been experimenting with the code below but it only adds/ updates the picture in Gmail -> Settings -> General -> My picture part of the user account and does not apply it to the actual profile picture i.e. the thumbnail in the top right of most Google Apps.

Is it possible to change the users profile picture also using GAS?

function updatePicture() { 

  try {       
    var userEmail = '------@------.com'; 
    var fileName  = userEmail + ".jpg";

    var blob = DriveApp.getFileById('-------------').getBlob();
    var data = Utilities.base64EncodeWebSafe(blob.getBytes());

   AdminDirectory.Users.Photos.update({photoData:data}, userEmail);
  }      
  catch (err) {
    Logger.log(err.toString());
  } 
}
pinoyyid
  • 21,499
  • 14
  • 64
  • 115
James D
  • 3,102
  • 1
  • 11
  • 21
  • Yes it is possible, you can check here in this [link](https://ctrlq.org/code/20123-update-gmail-user-picture) on how to Update Gmail Picture of Google Apps Users with Google Script. It provided some sample code that you can copy. The only problem here is the batching request. So just try to tweak some code here and try to implement the batching. – KENdi Mar 11 '17 at 14:22

0 Answers0