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());
}
}