PowerShell bulk modifies the computer to which the ad account is logged on

Source: Internet
Author: User

Powershell bulk modifies the computer to which the ad account is logged on

Last month, a project encountered such a requirement, the description of the process before the customer's actual situation: because of security considerations, the computer in the domain has been set to specify the login to the computer before, the current project is to migrate from the Lotus Mail system to exchange,Lotus workflow is migrated to pan-Micro OA, and you cannot log in to the Exchange system after you enter your account and password in the domain. The reason is to set the login to computer properties of the account, because Exchange is the new system, not within the specified scope, so you need to add Exchange Server cas01,cas02,mail,mailbox01. Add Mailbox01 because the public folder database is on MAILBOX01, WinXP clients need to connect to Mailbox01 to download and update the OAB.

And the user to determine the scope and work content, began to do, the user said he had saved before the batch import script, I say yes, you to deal with it, the results of a morning passed, until noon, not finished, I look, the script is more complex, for the OU to modify, some properties to adjust, One hours will be able to handle 500, according to this progress, the afternoon may also not finish.

Analysis after the idea came, first from the ad export the existing logonworkstation attribute to Excel, in the Excel batch modified under the logonworkstation attribute, in the import to the ad on it, so efficient and low failure rate.

The detailed implementation steps are described below.

Step 1, PowerShell batch export the relevant properties of AD. If the system is 2008, you will need to use import-moudle activedirectory to pour the ad module first, but it will be imported automatically in 2012.

PS c:\users\administrator> get-aduser-filter *-properties * | Select-object Name,samaccountname,userprincipalname,logo
nw*| Export-csv c:\userinfo.csv-Encoding utf8-notypeinformation

650) this.width=650; "title=" 1.jpg "style=" height:479px;width:703px; "alt=" Wkiom1swov6axsr0aae8tdl2mg8728.jpg "src= "Http://s3.51cto.com/wyfs02/M01/58/73/wKiom1Swov6AxSr0AAE8tDL2mg8728.jpg" width= "877" height= "619"/>

Step 2, after exporting, delete some system comes with account, for example.

650) this.width=650; "title=" 1.png "style=" height:590px;width:703px; "alt=" Wkiom1swpg6zapdpaaka87eufb4723.jpg "src= "Http://s3.51cto.com/wyfs02/M00/58/73/wKiom1SwpG6zaPDpAAKA87eUFB4723.jpg" width= "682" height= "586"/> Step 3, Below we add five columns of content, one column is cut from Logonworkstation, some are cas01, one column is CAS02, one is mail, and one column is mailbox01. Used for the following steps, "column merging". Why is the logonworkstation column left blank? Look at the following steps to know.

650) this.width=650; "title=" 1.png "style=" HEIGHT:557PX;WIDTH:707PX; "alt=" Wkiol1swpxuihoijaaogeetfbpc356.jpg "src= "Http://s3.51cto.com/wyfs02/M01/58/70/wKioL1SwpxuihoIjAAOgEetFbPc356.jpg" width= "854" height= "586"/>

Step 4, we use the Excel Word conformance and function, a&b&c&d&e, such as, get the xp002,cas01,cas02,mail,mailbox01 we want this effect, and pull to fill to the end of the line.

650) this.width=650; "title=" 1.png "style=" height:525px;width:708px; "alt=" Wkiol1swqq3thowaaas021rirty248.jpg "src= "Http://s3.51cto.com/wyfs02/M02/58/70/wKioL1SwqQ3THoWAAAS021rIRTY248.jpg" width= "965" height= "557"/>

Step 5, after editing, note to open the file with Notepad, and then select the "UTF-8" encoding to save the CSV file, in order to avoid the occurrence of the import after the text fragment garbled.

650) this.width=650; "title=" 1.png "style=" HEIGHT:419PX;WIDTH:709PX; "alt=" Wkiol1swqeurwnijaanc3s5jp6w080.jpg "src= "Http://s3.51cto.com/wyfs02/M00/58/70/wKioL1SwqeuRwNIJAANC3s5Jp6w080.jpg" width= "961" height= "538"/>

Step 6, copy the edited CSV file to C: \, execute the import command

PS c:\users\administrator> Import-csv-path C:\userinfo.csv | foreach {set-aduser-identity $_.name-logonworkstations $
_.logonworkstations}

650) this.width=650; "title=" 1.png "style=" height:496px;width:711px; "alt=" Wkiol1swqxfclz-0aaenoehm4qm150.jpg "src= "Http://s3.51cto.com/wyfs02/M00/58/71/wKioL1SwqxfCLZ-0AAEnOeHM4QM150.jpg" width= "878" height= "523"/>

Step 7, check the effect of our import, compare the Excel table to see if we meet the requirements.

650) this.width=650; "title=" 1.jpg "alt=" wkiom1swqt-txyywaaiufjvorcg403.jpg "src=" http://s3.51cto.com/wyfs02/M01/ 58/74/wkiom1swqt-txyywaaiufjvorcg403.jpg "/>

650) this.width=650; "title=" 1.jpg "style=" height:521px;width:712px; "alt=" Wkiol1swq_3d2sguaarwtiddz84506.jpg "src= "Http://s3.51cto.com/wyfs02/M02/58/71/wKioL1Swq_3D2SguAARWtidDZ84506.jpg" width= "889" height= "595"/>

Step 8, the entire import after the time of less than half an hour. To achieve our actual results, the steps are complete.

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/1601568

PowerShell bulk modifies the computer to which the ad account is logged on

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.