Powershell - Adding Pictures to Office 365 Accounts

powershell.jpg

How many times have you corresponded with a co-worker, and either as a result of company size, or physical location not recognized the person when you met them?  Doesn't it feel at sometimes like we have a relationship with someone who we would never recognize if we met them on the street?  These are the two primary reasons that adding images to your Active Directory, or Office 365 Accounts could prove beneficial. Second to that Social Uniformity both within the business and personally becomes more important as we are presenting online personas to the public.  We have all had the misfortune of "Googling" a person to find out more about them, whether it's for a hiring choice, or an upcoming meeting.  There is something to be said when there is a uniform presentation of who that person is vice, a professional image, and that of a wild night partying.  After all we are only human and consistently have outside factors sway our opinions and perceptions.

As an Example, Outlook does a great job of adding pictures from not only social media, but also within AD to present a face to the e-mail address.  As illustrated below you can see up in the "To" Section you can see the picture of the person who sent the message, then again at the bottom all those who are part of the conversation.

img_55355ca59719e.png

If this person was part of your organization who you communicated with often, this would give you the insight to recognize them that next Holiday Party or Company Picnic.

Another option is to use the Social Plugin from within Outlook to connect your contacts to LinkedIn.  This will also bring in pictures if the user information matches a LinkedIn Profile.  This is where the uniformity should take place, a company picture that is  uploaded, the same or similar professional picture to both your Linkedin Profile, as well as your company website should you be featured.

Below is a very easy powershell script to upload pictures to each of your end users.  It assumes that you have done the following:

  1. Set the files in path directory to match the UPN (UserPrincipalName of the user)
  2. And that they are jpg files.  If they are not you just need to alter the extension in the script.
######################################### # # # Connect to O365 # # # ######################################### $msolcred = get-credential connect-msolservice -credential $msolcred ######################################### # # # Exchange Online # # # ######################################### $UserCredential = $msolcred $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/?proxymethod=rps -Credential $UserCredential -Authentication Basic -AllowRedirection Import-PSSession $Session ######################################### # # # Set $Path to Path # # # ######################################### $users = Get-MsolUser foreach ($person in $users) { $path = "<PATH TO FILES>" $user = $person.UserPrincipalName $photo = $path+$user+".jpg" Set-UserPhoto -Identity $person.UserPrincipalName -PictureData ([System.IO.File]::ReadAllBytes($photo)) -Confirm:$false
 
Test