PowerShell Management Series (27) changes to PowerShell operation AD Custom properties

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

See a netizen sent me a message, consulting ad users how to add custom attributes, the following specific how to operate, to ask questions for users,

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/76/07/wKiom1ZInPuDdf_8AAAqLFNLPEY853.png "title=" QQ picture 20151115225539.png "alt=" Wkiom1zinpuddf_8aaaqlfnlpey853.png "/>

1, according to his request, we create a new CSV table, there are two columns of properties, one column is gender, one column is a sub-department, such as

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/76/05/wKioL1ZIoGvj2RDAAAEGkl3-coo933.png "title=" QQ picture 20151115225539.png "alt=" Wkiol1ziogvj2rdaaaegkl3-coo933.png "/>

2. Execute the following command

#创建空的哈希表值

$custom = @{}

#导入数据源userinfo. csv

Import-csv-path C:\userinfo.csv-Encoding default |% '

{

#增加属性性别和子部门

$custom. ExtensionAttribute1 = $_.sex

$custom. ExtensionAttribute2 = $_.dept

Set-aduser-identity $_. Samaccountname-add $custom

Get-aduser-identity $_. Samaccountname-pro *| Select-object Samaccountname,extensionattribute1,extensionattribute2

}

The results of the implementation are as follows:

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/76/08/wKiom1ZIpcOTU_wvAAFEqD1fFHA460.png "title=" QQ picture 20151115225539.png "alt=" Wkiom1zipcotu_wvaafeqd1ffha460.png "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/76/08/wKiom1ZIpwaSa-zFAADasOAKb7I064.png "title=" QQ picture 20151115225539.png "alt=" Wkiom1zipwasa-zfaadasoakb7i064.png "/>

3, we can also delete the added attributes, such as the following command

$custom = @{}

#导入数据源userinfo. csv

Import-csv-path C:\userinfo.csv-Encoding default |% '

{

#增加属性性别和子部门

$custom. ExtensionAttribute1 = $_.sex

$custom. ExtensionAttribute2 = $_.dept

Set-aduser-identity $_. Samaccountname-remove $custom

Get-aduser-identity $_. Samaccountname-pro *| Select-object Samaccountname,extensionattribute1,extensionattribute2

}

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/76/08/wKiom1ZIplbiBHlGAADqubNTkBA258.png "title=" QQ picture 20151115225539.png "alt=" Wkiom1ziplbibhlgaadqubntkba258.png "/>

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/76/05/wKioL1ZIpwmwT6BLAAC1nkrI4Ro988.png "title=" QQ picture 20151115225539.png "alt=" Wkiol1zipwmwt6blaac1nkri4ro988.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/1712986

PowerShell Management Series (27) changes to PowerShell operation AD Custom properties

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.