Disable clutter Office 365 primary domain

See if users have set a profile Picture in Office 365 with PowerShell by Bas Wijdenes

Microsoft office 365 and the user profile picture.

Within Microsoft Office 365 users can set up a Profile picture themselves. This is then synchronized to Skype for Business, Outlook, Yammer, Delve, and so on. The advantage of this is that users can recognize each other more easily and that the e-mails and Skype messages become more personal.

As a global administrator you have the option to change a profile picture for the user within the Office 365 admin portal. You can also set the profile picture with PowerShell.

Below I explain how you can check who has not set up a profile photo in Office 365, and how you can set these up for these people.


See if a user in Office 365 has a profile photo with PowerShell, the script and execution.

See the profile picture in O365 with PowerShell.
See the profile picture in O365 with PowerShell.

I tested the script with 4,000 users, and then the script takes quite a long time. If you are out of luck then time out your session. So maybe you can make some improvements in the script, but for now it does work.

The script first retrieves all mailboxes in Exchange, and then executes a foreach loop for each mailbox. If you do not get a photo back, and therefore an error message, the user does not yet have a photo in Office 365.

Finally, in $data you have all users, whether or not they have a profile photo. You can see this with the property PhotoEnabled.

You can also download the script from Technet Script Center.
Click here for the downloadable link.

$mailboxes = get-mailbox -ResultSize unlimited
$data = @()

foreach ($mbx in $mailboxes)

{

$dataobject=New-Object psobject

$dataobject|add-member-NotePropertyName UserPrincipalName -NotePropertyValue $mbx.userprincipalname

$photo=get-userphoto$mbx.userprincipalname

if(!($photo)){

$dataobject|Add-Member-NotePropertyName PhotoEnabled -NotePropertyValue "No"

}else{

$dataobject|Add-Member-NotePropertyName PhotoEnabled -NotePropertyValue "Yes"

}

$Data+=$dataobject

}

You can also export the information with the following cmdlet:

$data | Export-Csv C:\LOCATION -NoTypeInformation

Recap

If you have questions, comments, or improvements for the script, you can indicate this in the comments.
Do you see something different, or a mistake? Please leave a comment.


A little extra

This post contains PowerShell. Would you like to learn the basics better? I have created a new website to learn basic PowerShell in an ’emulator’ environment.
Click here to go learn Basic PowerShell.

Published by

Bas Wijdenes

My name is Bas Wijdenes and I work full-time as a Services Engineer. In my spare time I write about the error messages that I encounter during my work. Furthermore, I am currently occupied with Office 365, Azure infra, and PowerShell for automating daily tasks.

One thought on “See if users have set a profile Picture in Office 365 with PowerShell by Bas Wijdenes”

  1. Hi Bas,

    there are some spaces missing in the script e.g. add-member-notepropertyname and at get-userphoto$mbx.userprincipalname

    If you check the mailbox property HasPicture it is much faster than trying to get-userphoto and checking the result

    grtz,

    Bart

Leave a Reply

Your email address will not be published. Required fields are marked *