7UD9 Posted July 31, 2015 Posted July 31, 2015 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
halbaradkenafin Posted July 31, 2015 Posted July 31, 2015 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. 1
Geoff Posted July 31, 2015 Posted July 31, 2015 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 } 1
7UD9 Posted July 31, 2015 Author Posted July 31, 2015 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
Geoff Posted July 31, 2015 Posted July 31, 2015 Yeah, looks ok. You should be able to add -WhatIf to your Remove-UserPhoto and you can test it without actually doing anything. 1
7UD9 Posted July 31, 2015 Author Posted July 31, 2015 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.
jamesb Posted July 31, 2015 Posted July 31, 2015 Try -Confirm:$False on the end of the Remove-UserPhoto line. 1
7UD9 Posted July 31, 2015 Author Posted July 31, 2015 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
Geoff Posted July 31, 2015 Posted July 31, 2015 I think it's just -Confirm. https://technet.microsoft.com/en-us/library/jj218610(v=exchg.150).aspx 1
7UD9 Posted July 31, 2015 Author Posted July 31, 2015 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now