vbs下用一個小方法實現(xiàn)批量添加域用戶
更新時間:2008年06月15日 20:58:00 作者:
在域模式下批量添加域用戶就有些困難,下面是一個vbs腳本,在同級目錄下用放置一個users.txt的文本文檔,格式:username,password,在dc上運行該腳本,即可以將users.txt的用戶信息批量添加到ad里面??梢酝ㄟ^移動或拖拽的方法,將生成的用戶移動到ou下面,以保證ou的組策略及文件夾重定向對該用戶生效。
復制代碼 代碼如下:
set adsou=getobject("ldap://cn=users,dc=hzcncter,dc=local")
const forreading = 1
set objfso = createobject("scripting.filesystemobject")
set objtextfile = objfso.opentextfile _
("users.txt", forreading)
do until objtextfile.atendofstream
strnextline = objtextfile.readline
arruserlist = split(strnextline , ",")
struser=arruserlist(0)
strpass=arruserlist(1)
set adsuser=adsou.create("user","cn=" & struser)
adsuser.put "samaccountname", struser
adsuser.put "userprincipalname", struser & "@hzcncter.local"
adsuser.setinfo
adsuser.setpassword strpass
adsuser.accountdisabled=false
adsuser.setinfo
loop
注意保存后,更改一下dc名稱(紅色字體),如果ou名稱是英文,也可以連ou名稱一起更改,這樣就可以直接將用戶建立到ou里面。
相關文章
教你編寫Windows的VBScript與Mac的AppleSCript腳本解放雙手
這篇文章主要介紹了教你編寫Windows的VBScript腳本與Mac的AppleSCript腳本來解放大家的雙手,有需要的朋友可以借鑒參考下,希望能夠有所幫助2022-02-02