{"id":426,"date":"2019-05-08T14:40:18","date_gmt":"2019-05-08T19:40:18","guid":{"rendered":"http:\/\/itblog.ldlnet.net\/?p=426"},"modified":"2019-05-08T14:40:18","modified_gmt":"2019-05-08T19:40:18","slug":"importing-user-photos-to-office-365-in-bulk-for-your-company","status":"publish","type":"post","link":"https:\/\/itblog.ldlnet.net\/index.php\/2019\/05\/08\/importing-user-photos-to-office-365-in-bulk-for-your-company\/","title":{"rendered":"Importing User Photos to Office 365 in bulk for your company."},"content":{"rendered":"\n<p>In a previous post, I showed how you could update one user&#8217;s photo for their Outlook and AD profiles via PowerShell. In this post, we will explore how to do this for your entire organization via PowerShell to Office365.<\/p>\n\n\n\n<p class=\"has-text-color has-small-font-size has-medium-pink-color\"><strong>NOTE: I have not tested the scripts as I do not have enough mailboxes in my O365 tenant along with not using a &#8216;.&#8217; in my alias. If the scripts are incorrect, please inform me with the correction and I will update accordingly.<\/strong><\/p>\n\n\n\n<p>Please make sure that your photos are reviewed before posting, and try to keep the file size of the photos to a minimum. In Office 365, there exists a limitation for the user photo not to be more than 10 KB in size, but I will show you how to get around that limitation.<\/p>\n\n\n\n<p>Having a user photo for each of your users is very beneficial as it personalizes each account to a face in the company. The user photos can be viewed in below locations:\n\n                        \n                        <\/p>\n\n\n\n<ul class=\"wp-block-list\"><li> Outlook Web Access<\/li><li> Contact Card<\/li><li> Thumbnail in emails<\/li><li> Outlook Client<\/li><li> Yammer<\/li><li> Lync Client<\/li><li> SharePoint (People Search \/ Newsfeed)<\/li><\/ul>\n\n\n\n<p>Steps to take:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Remove the 10KB photo size limitation in Exchange Online<\/li><li>Prepare a folder with all users photos<\/li><li>Update the profile photos via a PowerShell cmdlet.<\/li><\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" style=\"text-align:left\">Connect to Exchange Online with the RPS Proxy Method to remove the 10K size limitation<\/h3>\n\n\n<pre class=\"lang:PowerShell nums=False\" title=\"Connect to Exchange Online PowerShell removing the 10K limitation\">$UserCredential = Get-Credential\n$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https:\/\/outlook.office365.com\/powershell-liveid\/?proxyMethod=RPS -Credential $UserCredential -Authentication Basic -AllowRedirection\nImport-PSSession $Session<\/pre>\n\n\n\n<p class=\"has-text-color has-small-font-size has-medium-pink-color\"><strong>NOTE:<\/strong> In the PowerShell cmdlet above, we connected using a different proxy method. This was to overwrite the limitation of uploading the images with size more than 10KB. Using the different proxy method (<strong>\/?proxyMethod=RPS<\/strong> ) to connect to Office 365 in the above cmdlet accomplishes this.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" style=\"text-align:left\">Prepare a folder locally and place all the photos in that folder<\/h3>\n\n\n\n<p>Create a folder named <em>C:\/UserPics<\/em> and make the filename of each photo be the username of that particular user. (i.e. <em>llingerfelt.png<\/em>)<br>The below script should be able account for aliases that have a &#8216;.&#8217; in the id as well. (i.e. lance.lingerfelt)<br><\/p>\n\n\n\n<p class=\"has-text-color has-small-font-size has-medium-pink-color\"><strong>NOTE: <\/strong>From my research, there is no set photo type that is required for the photo. My suggestion would be to keep the photos <em>.png<\/em> for size constraints while maintaining picture clarity.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" style=\"text-align:left\">Update the profile pictures via PowerShell<\/h3>\n\n\n\n<p>Create the following script and name it <em>Photos-Update.ps1<\/em><\/p>\n\n\n<pre class=\"lang:PowerShell nums:False\" title=\"Photos-Update.ps1\">$path= 'C:\\UserPics\\'\n$Images = Get-ChildItem $path\n$Images |Foreach-Object{\n$Identity = ($_.Name.Tostring() -replace '.png','')\n$PictureData = $path+$_.name\nSet-UserPhoto -Identity $Identity -PictureData ([System.IO.File]::ReadAllBytes($PictureData)) -Confirm:$false }\n<\/pre>\n\n\n\n<p>Run <em>Photos-Update.ps1<\/em> and the script should upload the photos to Office 365 and apply each photo to the corresponding user.<\/p>\n\n\n\n<p class=\"has-text-color has-small-font-size has-medium-pink-color\"><strong>NOTE: If you&#8217;re still having some issues with the alias having a &#8216;.&#8217; in the name, you can also configure the Photos-Update.ps1 script in this manner to get that working properly:<\/strong><\/p>\n\n\n<pre class=\"lang:PowerShell nums:False\" title=\"Photos-Update.ps1 alternate version\">$path= 'C:\\UserPics\\'\n$Images = Get-ChildItem $path\n$Images |Foreach-Object{\n$Identity = ($_.Name.Tostring() -split \"\\.\")\n$count = $Identity.count\nIf($count -gt 2)\n{\nfor($i=0; $i -le $count-2; $i++)\n{\n$username=$username+$Identity[$i]+\".\"\n}\n$Id=$username.TrimEnd(\".\")\n}\nElse\n{\n$Id=$Identity[0]\n}\n$PictureData = $path+$_.name\nSet-UserPhoto -Identity $Id -PictureData ([System.IO.File]::ReadAllBytes($PictureData)) -Confirm:$false\n$username=$null\n}\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"text-align:center\">HAPPY SCRIPTING!<br>PLEASE COMMENT!<\/h2>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"728\" height=\"90\" src=\"http:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2019\/05\/LDLNET-Leaderboard-728x90.png\" alt=\"store.ldlnet.net\" class=\"wp-image-423\" srcset=\"https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2019\/05\/LDLNET-Leaderboard-728x90.png 728w, https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2019\/05\/LDLNET-Leaderboard-728x90-300x37.png 300w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><figcaption>LDLNET LLC! Your Source for Pofessional IT Services!<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/www.servermonkey.com\/?utm_source=ldlnet.net&amp;utm_medium=referral\" target=\"_blank\" rel=\"noopener noreferrer\"><img loading=\"lazy\" decoding=\"async\" width=\"468\" height=\"61\" src=\"https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2019\/05\/banner-100.jpg\" alt=\"www.servermonkey.com\" class=\"wp-image-427\" srcset=\"https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2019\/05\/banner-100.jpg 468w, https:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2019\/05\/banner-100-300x39.jpg 300w\" sizes=\"auto, (max-width: 468px) 100vw, 468px\" \/><\/a><figcaption>Contact ServerMonkey.com for your IT Hardware Needs!<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"has-small-font-size\"><strong><em>REFERENCES:<\/em><\/strong><br><a href=\"https:\/\/www.jijitechnologies.com\/blogs\/update-office365-user-photo-in-bulk\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"How to import Office365 User photos over 10KB &amp; without CSV in bulk (opens in a new tab)\">How to import Office365 User photos over 10KB &amp; without CSV in bulk<\/a><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In a previous post, I showed how you could update one user&#8217;s photo for their Outlook and AD profiles via PowerShell. In<\/p>\n<p class=\"link-more\"><a class=\"myButt \" href=\"https:\/\/itblog.ldlnet.net\/index.php\/2019\/05\/08\/importing-user-photos-to-office-365-in-bulk-for-your-company\/\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":209,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[48,4,2,111,3,16],"tags":[15,9,78,8,13],"class_list":["post-426","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-active-directory","category-exchange","category-general","category-outlook","category-powershell","category-windows","tag-cmdlet","tag-exchange","tag-exchange-onlilne","tag-powershell","tag-script","odd"],"_links":{"self":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/426","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/comments?post=426"}],"version-history":[{"count":2,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/426\/revisions"}],"predecessor-version":[{"id":429,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/426\/revisions\/429"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/media\/209"}],"wp:attachment":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/media?parent=426"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/categories?post=426"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/tags?post=426"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}