Jump to content

[Powershell] Remove-UserPhoto Exchange 2013


Recommended Posts

Posted

Hi all

 

My aim is to reset all profile photos in Exchange/Outlook Web Access.

 

This can be done for individual users by running the following;

 

Remove-UserPhoto "Username"

 

What I can't work out is how to do this for all of our users, or at least all of our students. Many have set their photos to inappropriate images. I now know how to prevent them doing this in the future but I still need to reset/clear the current ones.

 

Does anyone have any suggestions which are better than going through hundreds of users one at a time?

 

TIA

Posted
I'd imagine you can pipe Get-Mailbox to it and do it that way to wipe out everyone's photos, or you could probably pipe something from AD to it. I'd expect the first one to be the best one to try though.
  • Thanks 1
Posted

You need a for each loop. Assuming you have a security group of all these students, something this should work.

 

$users = Get-ADGroupMember -identity "GROUPNAME" -Recursive 

foreach ($user in $users) {
Remove-UserPhoto $user.SamAccountName
}

  • Thanks 1
Posted
You need a for each loop. Assuming you have a security group of all these students, something this should work.

 

$users = Get-ADGroupMember -identity "GROUPNAME" -Recursive 

foreach ($user in $users) {
Remove-UserPhoto $user.SamAccountName
}

 

We do, domain\students.

 

So my code would be as follows?

 

$users = Get-ADGroupMember -identity "Students" -Recursive 

foreach ($user in $users) {
Remove-UserPhoto $user.SamAccountName
}

 

Thanks

Posted
Yeah, looks ok. You should be able to add -WhatIf to your Remove-UserPhoto and you can test it without actually doing anything.
  • Thanks 1
Posted

That looks perfect, thank you!

 

One last thing...

 

Is there a way to force Yes on a "do you wish to proceed with this action" prompt? It's asking for each action.

Posted
Try -Confirm:$False on the end of the Remove-UserPhoto line.

 

Tried that, no luck.

 

I've started it off and resorting to spamming the enter key :rolleyes:

Posted

All done, thank you for the help, it's much appreciated.

 

I never got to the bottom of -Confirm, spamming enter did the trick this time.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...