今天接到一个任务,一个子公司100来个USER的账号,更换了新的电话号码,另顺便需要在AD里面体现出

各USER的职位。


好吧,100多个人,如果手动来改,量也很大,首先想到的是用脚本来修改,刚好想到了powershell。


首先,准备一个CSV文件,把USER按如下格式排练好,各值之间用逗号隔开,之后命名test.csv文件

samaccountname,telephonenumber,title

   user1,1234567,engineer

   user2,2345678,sales

    ...,....,....,


调出powershell命令

import-csv c:\test.csv | %{set-aduser -identity $_.samaccountname -replace @{telephonenumber=$_.telephonenumber;title=$_.title}}


这样,一个命令就解决了,不需要在一个一个去修改了。