Link to home
Start Free TrialLog in
Avatar of Daniele Brunengo
Daniele BrunengoFlag for Italy

asked on

Microsoft 365: remove user photo for all users

Hello, we are using M365 at a school and we'd like to keep users from changing their profile photo.

Now, that should already be enable, the problem is many users already had changed their photo.

What I'd need is to remove (not replace) the photo, so that on Teams the icon with initials shows up. Basically, teachers need to see initials all the time while on a Teams meeting.

I tried following a couple of guides to do this with PowerShell and it seems to work with no error, but then I check and the photos are still there.

This is what I did and I thought it had worked:

$Users = Get-AzureADUser | Where {$_.UserType -eq 'Member' -and $_.AssignedLicenses -ne $null}
 
foreach ($user in $Users) {Remove-UserPhoto -Identity $user.UserPrincipalName -Confirm$false}

Open in new window

Avatar of Scott Fell
Scott Fell
Flag of United States of America image

I am not a pro at PS but looking at Get-AzureADUser https://docs.microsoft.com/en-us/powershell/module/azuread/get-azureaduser?view=azureadps-2.0 and Remove-UserPhoto https://docs.microsoft.com/en-us/powershell/module/exchange/remove-userphoto?view=exchange-ps what you have looks right.

If you try to manually code Remove-UserPhoto does it work?  Also, it may take hours for things to propagate in MS and that could be the issue.
Avatar of Daniele Brunengo

ASKER

Yeah I thought about that, but it's been more than 12 hours. I'll try with a single user and report back.
There are several different places where photos can be stored within O365, and the cmdlet above doesnt cover them all. In fact, nothing does, at least not currently. MS is in the process of reworking this, or at least that was the answer I got last time I poked around the subject.

Just in case, check whether you can see the photos from within a private browser session, as Teams caches things locally, and the process above might have worked, but you are still seeing the locally cached image.
Ok, I'll use the private browser. Teams is the only concern here, that's basically the only service the school's been using intensively.
I'll check again tomorrow. Right now, it doesn't seem to work. I tried applying the command to a single user and I tried browsing with a private session.
It's quite ludicrous there isn't an easy way to just remove all images and reset each user to his initials as a "placeholder" image.

I logged into my admin panels to see if I could come up with anything and didn't see anything easy.

Just to think out loud, perhaps impersonating users and removing their avatars https://docs.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-configure-impersonation  and maybe giving rights to the admin to all users may do the trick. I don't have an easy way to test without warning some people first.
I have too many users, it would take ages. I don't think there's a comprehensive way to do this, that's the way it looks like right now.
I understand. I wonder if you can impersonate via powershell or at least set up admin to impersonate, then use admin privs to loop through users via powershell is what I was getting at. 
As far as I can tell you can't. Those commands I used are quoted in many articles, but they don't seem to cover the whole range of possibilities.

I have found a free utility, CodeTwo User Photos for Office 365, which actually allows to change each user profile image, and it works. But you can't just reset to no image. If you remove the image, it gets replaced with the same ugly image (a grey bust).

https://www.codetwo.com/freeware/user-photos-for-office-365/
The fact that a third party product can do this tells me what I am suggesting is possible. Since you found that, just replace with some type of 'blank' image you want. You can use a solid white or gray square, logo, or a different silhouette.  
Already done, trouble is we need no user image to be defined. When no image is defined, the system defaults to a circle with the user's initials, which is what teachers would prefer. But the software doesn't allow to return to no image.

ASKER CERTIFIED SOLUTION
Avatar of Daniele Brunengo
Daniele Brunengo
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial