#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
Feedback sent
We appreciate your effort and will try to fix the article