{"id":974,"date":"2014-10-07T06:49:06","date_gmt":"2014-10-07T06:49:06","guid":{"rendered":"https:\/\/poiseddevelopers.com\/reality-tech\/?p=974"},"modified":"2024-04-26T12:33:05","modified_gmt":"2024-04-26T12:33:05","slug":"uploading-pictures-into-activedirectory-remotely-via-powershell","status":"publish","type":"post","link":"https:\/\/poiseddevelopers.com\/reality-tech\/uploading-pictures-into-activedirectory-remotely-via-powershell\/","title":{"rendered":"Uploading pictures into ActiveDirectory remotely via PowerShell"},"content":{"rendered":"<p>One can upload pictures into PowerShell remotely. A few requirements:<br role=\"presentation\" data-uw-rm-sr=\"\" \/>1. Install RSAT; ; that\u2019s adding the Feature in Computer Management<br role=\"presentation\" data-uw-rm-sr=\"\" \/>2. Have remote web services running on AD<br role=\"presentation\" data-uw-rm-sr=\"\" \/>3. Have sufficient access; you must be member of either the Organization Management or Recipient Management role groups to upload the pictures.<br role=\"presentation\" data-uw-rm-sr=\"\" \/>4. Have a set of photos, preferably named with the user accounts, JPGs, 96\u00d796 and less than 10kb<\/p>\n<p>Here\u2019s what\u2019s needed in PowerShell to get started using AD CmdLets:<\/p>\n<pre lang=\"php\">Import-module ActiveDirectory\r\nif ((Get-PSSnapin -Name ActiveDirectory -ErrorAction SilentlyContinue) -eq $null ){\r\n            import-module ActiveDirectory\r\n}\r\n<\/pre>\n<p>here\u2019s how to see the existing picture for a given user:<\/p>\n<pre lang=\"php\">$user = Get-ADUser [user] -Properties thumbnailphoto\r\n$user.thumbnailphoto.length\r\n$user.thumbnailphoto | Set-Content \"C:tempJtest3a.jpg\" -Encoding byte -Force\r\n<\/pre>\n<p>Testing in Outlook: Pictures are cached in Outlook for the duration of the session. To check whether the picture is available, one has to totally exit Outlook.<\/p>\n<pre lang=\"php\">$LocalFiles = get-childitem -Path $WorkingPath -filter $TypeFilter | where {!$_.PSIsContainer}\r\n<\/pre>\n<p>To upload the picture, get the user:<\/p>\n<pre lang=\"php\">\t\r\n$User = Get-ADUser -Filter {SamAccountName -eq $Name}\r\n<\/pre>\n<p>Let\u2019s get the photo after resizing to 96\u00d796 ensuring it is less than 10k<\/p>\n<pre lang=\"php\">\r\n$Photo = [byte[]](Get-Content \"$WorkingPath$File\" -Encoding byte)\r\nSet-ADUser $Name -Replace @{thumbnailPhoto=$Photo}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>One can upload pictures into PowerShell remotely. A few requirements:1. Install RSAT; ; that\u2019s adding the Feature in Computer Management2. Have remote web services running on AD3. Have sufficient access; you must be member of either the Organization Management or Recipient Management role groups to upload the pictures.4. Have a set of photos, preferably named [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":977,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[26],"tags":[],"class_list":["post-974","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"_links":{"self":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/974","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/comments?post=974"}],"version-history":[{"count":12,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/974\/revisions"}],"predecessor-version":[{"id":1002,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/974\/revisions\/1002"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/media\/977"}],"wp:attachment":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/media?parent=974"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/categories?post=974"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/tags?post=974"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}