PowerShell Management Series (24) PowerShell Operations batch enable Exchange user picture

Source: Internet
Author: User
Tags samaccountname

-----provide ad\exchange\lync\sharepoint\crm\sc\o365 and other Microsoft product implementation and outsourcing, qq:185426445. Phone 18666943750

because organizations are large, employees in branch offices may not know each other, and in addition to displaying contact information in the GAL, they can display his photos. There are two ways to import pictures in Exchange Server 2013, one of which is to use theImport-Recip Ientdataproperty, but there is a limit to the size of the picture, file, And not greater than ten KB, the second is the use of Set-userphoto,


The following explains the use of Set-userphoto to set up Exchange user pictures in bulk

The TechNet reference syntax is as follows:

Link: https://technet.microsoft.com/ZH-CN/library/jj218694 (v=exchg.150). aspx

Set-userphoto "Paul Cannon"-picturedata ([System.io.file]::readallbytes ("C:\Users\Administrator\Desktop\ Paulcannon.jpg "))


Method 1, using CSV Import

Step 1, new staff information CSV, import into Exchange, for example, create a new column of values, take the sAMAccountName value in the ad,

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/75/F7/wKioL1ZGBcuCTq81AADO-l5u7F8133.png "style=" float: none; "title=" 1.png "alt=" Wkiol1zgbcuctq81aado-l5u7f8133.png "/>

Step 2, the value of the picture is consistent with the value of the CSV, and both the picture and the CSV file are copied to the server's C:\photo

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/75/F9/wKiom1ZGBYCheV0BAAB8KYHNBcs758.png "style=" float: none; "title=" 2.png "alt=" Wkiom1zgbychev0baab8kyhnbcs758.png "/>

Step 3, use the following command to bulk Import pictures,

Add-pssnapin microsoft.exchange*

Import-csv-path C:\photo\userphoto.csv-encoding Default | %{set-userphoto $_.sam-picturedata ([System.io.file]::readallbytes ("C:\photo\" +$_.sam+ ". png"))-confirm: $false}

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/75/F9/wKiom1ZGCvKCisEKAAG8qWSAS1k789.png "title=" 1.png " alt= "Wkiom1zgcvkcisekaag8qwsas1k789.png"/>


Method 2, direct query ad account, in the batch import pictures, the command is as follows, the purpose of Test-path is to query whether there is a picture name of the same name of the ad account,

Get-aduser-filter *-searchbase "ou=contoso,dc=contoso,dc=com"

|? {Test-path ("C:\photo\" +$_. samaccountname+ ". png")} '

|%{set-userphoto $_. Samaccountname-picturedata ([System.io.file]::readallbytes ("C:\photo\" +$_. samaccountname+ ". png"))-confirm: $false}

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/75/F7/wKioL1ZGCFLCXBnmAAFNXPuM3kg080.png "title=" 2.png " alt= "Wkiol1zgcflcxbnmaafnxpum3kg080.png"/>

The results of the import are as follows:

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/75/F9/wKiom1ZGCK3RRDi9AACpD3BUIQ8107.png "style=" float: none; "title=" 1.png "alt=" Wkiom1zgck3rrdi9aacpd3buiq8107.png "/>

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/75/F9/wKiom1ZGCK7RHmetAACmSxRVM7U387.png "style=" float: none; "title=" 2.png "alt=" Wkiom1zgck7rhmetaacmsxrvm7u387.png "/>




650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/75/F7/wKioL1ZGCJ2SHgpzAACl39k6s60870.png "title=" 2.png " alt= "Wkiol1zgcj2shgpzaacl39k6s60870.png"/>











This article is from the "Zhou Ping Microsoft Technology Exchange Platform" blog, please be sure to keep this source http://yuntcloud.blog.51cto.com/1173839/1712651

PowerShell Management Series (24) PowerShell Operations batch enable Exchange user picture

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.