资源描述:
《VBS脚本实例演示教学.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、VBS脚本实例说明:本文中所列出的脚本实例,均为本人因日常工作需要所写,已在生产环境中验证并使用(参数请自行修改),希望可以帮到有需要的人。但本人并非非常熟悉VBS脚本,属于现学现卖的,欢迎批评指正或是与VBS/PowerShell脚本相关的技术交流。谢谢!1AD相关1.1迁移用户/计算机到指定OU**************************************************************************************
onerrorresumenextSetfso=CreateObje
2、ct("Scripting.FileSystemObject")
Setbasefile=fso.OpenTextFile("C:base.txt",1)
SetWSshell=CreateObject("Wscript.shell")
Do Until basefile.AtEndOfLine=-1 '读取txt文件,直到最后一行结束
base=basefile.ReadLine
comm="cmd/cecho"&base&">>C:resualt.txt"
WSshell.runcomm,0,true
Iffso.f
3、ileexists("C:"&base&".txt")Then '判断是否有指定OU的txt文件
Setfile=fso.OpenTextFile("C:"&base&".txt",1) '打开文件
Count=0
ErrorCount=0
disabledCount=0
Do Untilfile.AtEndOfLine=-1
name=file.ReadLine 'name形如:cn=test123,ou=test,dc=abc,dc=com ab
group=Right(name,2)
4、
Err.Number=0
IfLCase(group)="ab"Then
name=Left(name,Len(name)-3)
'wscript.echoname
SetUserObj=GetObject("LDAP://"&name)
'wscript.echoerr.number
IfErr.Number=0Then
IfUserObj.AccountDisabled=FALSEThen
strNewParentDN="ou="&base&"
5、,ou=personnel,ou=ab,DC=abc,DC=com"
setobjCont=GetObject("LDAP://"&strNewParentDN)
objCont.MoveHere"LDAP://"&name,vbNullString
Count_dc=Count_dc+1
else
strNewParentDN="ou=personel,ou=disabledAccounts,DC=abc,DC=com"
setobjCont=Get
6、Object("LDAP://"&strNewParentDN)
objCont.MoveHere"LDAP://"&name,vbNullString
disabledCount=disabledCount+1
EndIf
Else
ErrorCount=ErrorCount+1
comm="cmd/cechodc>>C:resualt.txt"
WSshell.runcomm,0,true
comm="cmd/cecho"&name&">>C
7、:resualt.txt"
WSshell.runcomm,0,true
EndIf
Else
name=Left(name,Len(name)-6)
SetUserObj=GetObject("LDAP://"&name)
IfErr.Number=0Then '
IfUserObj.AccountDisabled=FALSEThen
strNewParentDN="ou="&base&",ou=personnel,ou=ab,DC=abc,DC=c
8、om"
setobjCont=GetObject("LDAP://"&strNewParentDN)
objCont.MoveHere"LDAP://"&nam