VBS脚本实例

VBS脚本实例

ID:40755548

大小:20.08 KB

页数:10页

时间:2019-08-07

VBS脚本实例_第1页
VBS脚本实例_第2页
VBS脚本实例_第3页
VBS脚本实例_第4页
VBS脚本实例_第5页
资源描述:

《VBS脚本实例》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、VBS脚本实例说明:本文中所列出的脚本实例,均为本人因日常工作需要所写,已在生产环境中验证并使用(参数请自行修改),希望可以帮到有需要的人。但本人并非非常熟悉VBS脚本,属于现学现卖的,欢迎批评指正或是与VBS/PowerShell脚本相关的技术交流。谢谢!1AD相关1.1迁移用户/计算机到指定OU************************************************************************************** onerrorresumenextSetfso=CreateObject("S

2、cripting.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.fileexists("C:"&

3、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)   Err.Number=0   IfLCase(g

4、roup)="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&",ou=personnel,ou=ab,DC=abc,DC=com"      

5、  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=GetObject("LDAP://"&strNewParentDN)        objCont.Mo

6、veHere"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:resualt.txt"     WSshell.runcomm,0,true    EndIf   Else     

7、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=com"        setobjCont=GetObject("LDAP://"&strNewParentDN)        objCont.M

8、oveHere"LDAP://"&name,vbNullString      Count_dcits=Count_dcits+1   

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。