Jump to content

Recommended Posts

Posted

Morning All,

 

I am having an issue where students where able to change there O365 profile pictures. We have changed this so they can no longer do so but the majority have already changed there's and some are inappropriate. I have created and imported a CSV and ran a powershell script to to remove the picture from exchange online using the usernames in the CSV file. The script runs without error but doesn't actually remove the pictures. IN some strange cases if the user has had 2 pictures it just reverts the picture back to the first one that they used. I have raised this with Microsoft who confirmed the script is fine and said that this "should work but might not" and if it doesn't scripting is not supported. This is the script i have used:

 

$users = Import-CSV -Path "~\Desktop\userlist.csv"

foreach ($user in $users) {Remove-UserPhoto -identity $user.email -Confirm $false}

 

 

I can see that it reads the usernames and runs through the list (takes some time) but doesn't actually remove the images. Any help would be greatly appreciated.

 

Kind Regards

Mike

Posted

I ended up running this code:

 

$Result=@()
$allUsers = Get-Mailbox -RecipientTypeDetails UserMailbox -ResultSize Unlimited
$totalusers = $allUsers.Count
$i = 1 
$allUsers | ForEach-Object {
$user = $_
Write-Progress -activity "Processing $user" -status "$i out of $totalusers completed"
$photoObj = Get-Userphoto -identity $user.UserPrincipalName -ErrorAction SilentlyContinue
$hasPhoto = $false
if ($photoObj.PictureData -ne $null)
{
$hasPhoto = $true
}
$Result += New-Object PSObject -property @{ 
UserName = $user.DisplayName
UserPrincipalName = $user.UserPrincipalName
HasProfilePicture = $hasPhoto
}
$i++
}
$Result | Export-CSV "D:\office-365-users-photo-status2.csv" -NoTypeInformation -Encoding UTF8

 

Then created a list from that of users with photos and copied in to powershell manually the code to remove each one.

 

- - - Updated - - -

 

Morning All,

 

I am having an issue where students where able to change there O365 profile pictures. We have changed this so they can no longer do so but the majority have already changed there's and some are inappropriate. I have created and imported a CSV and ran a powershell script to to remove the picture from exchange online using the usernames in the CSV file. The script runs without error but doesn't actually remove the pictures. IN some strange cases if the user has had 2 pictures it just reverts the picture back to the first one that they used. I have raised this with Microsoft who confirmed the script is fine and said that this "should work but might not" and if it doesn't scripting is not supported. This is the script i have used:

 

$users = Import-CSV -Path "~\Desktop\userlist.csv"

foreach ($user in $users) {Remove-UserPhoto -identity $user.email -Confirm $false}

 

 

I can see that it reads the usernames and runs through the list (takes some time) but doesn't actually remove the images. Any help would be greatly appreciated.

 

Kind Regards

Mike

 

It can also take a few days for the images to be removed I think.

  • Thanks 1
Posted

Hi there,

 

We have had similar and I use the that command without the -Confirm $false, but only had a handful to do and i wanted to see the user id and checked each on Azure.

 

Were are you checking the photos? Azure ?

 

Just i know that for Teams it can take upto 24 hrs for it to update and then the desktop app can cache the old ones.

 

Thanks

  • Thanks 1
Posted

@tri_94

 

I am checking them in O365 admin centre. We ran the script about 3/4 weeks ago and since then it has been with Microsoft. They couldnt get it to work so replied saying scripting is not supported.

 

Thanks for you advice.

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...