Download all o365 users Display Photo

Modified on Tue, 30 Jun at 2:57 PM

#Input Parameters:

$folderpath="D:\naufil\pwshpic\" 


#Download all user profile pictures from Office 365:

New-Item -ItemType directory -Path $folderpath –force 

$allUsers=Get-Mailbox -RecipientTypeDetails UserMailbox -ResultSize Unlimited|select UserPrincipalName,Alias

Foreach($user in $allUsers)

{

$path=$folderpath+$user.Alias+".Jpg"

$photo=Get-Userphoto -identity $user.UserPrincipalName -ErrorAction SilentlyContinue

If($photo.PictureData -ne $null)

{

[io.file]::WriteAllBytes($path,$photo.PictureData)

Write-Host $user.Alias “profile picture downloaded”

}

}            

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article