ad常用脚本

上传人:简****9 文档编号:109719094 上传时间:2019-10-27 格式:DOC 页数:11 大小:50KB
返回 下载 相关 举报
ad常用脚本_第1页
第1页 / 共11页
ad常用脚本_第2页
第2页 / 共11页
ad常用脚本_第3页
第3页 / 共11页
ad常用脚本_第4页
第4页 / 共11页
ad常用脚本_第5页
第5页 / 共11页
点击查看更多>>
资源描述

《ad常用脚本》由会员分享,可在线阅读,更多相关《ad常用脚本(11页珍藏版)》请在金锄头文库上搜索。

1、*程序开始*DB_Path=bj-mgr-02SHAREDB_Mailcount.accdb设置数据库路径信息Set fso = Createobject(Scripting.FileSystemObject)set Write_list= fso.Getfile(result.ps1)set W_Data=Write_list.OpenAsTextStream(2,0)OptType=InputBox(请输入您要做的事的编号:&Chr(10)&1 创建邮箱&Chr(10)&2 核查账户&Chr(10)&3 创建账户&Chr(10)&4 删除邮箱或账户&Chr(10)&5 邮箱扩容&Chr(1

2、0)&6 用户加组,参数输入)User_list=Get_user()Select Case OptTypeCase 1Create_Mailbox()Case 2Check_User()Case 3Create_User()Case 4Delete_MBX()Case 5Expend_Content()Case 6Add_Group()Case elseMsgbox 请选择您要进行的操作!WScript.quitEnd SelectMsgbox success!W_Data.closeSet adocon= Nothing*程序结束*获取用户列表*Function Get_user() se

3、t Get_list= fso.Getfile(usrlist.txt) set Read_list=Get_list.OpenAsTextStream(1,0) Str_user=Read_list.ReadAll if Right(Str_user,1) = Chr(10) then Str_user=left(Str_user,Len(Str_user)-2) End if Get_user=Split(Str_user,Chr(13)&Chr(10)Read_list.closeEnd Function*检索用户所属企业*Function Check_Mark()PPoint=InSt

4、rRev(User_list(0),.)If PPoint 0 thenCheck_Mark =Right(User_list(0),Len(User_list(0)-InStrRev(User_list(0),.)elseCheck_Mark=headEnd ifEnd Function*生成创建邮箱脚本*FunctionCreate_Mailbox()set adocon=Createobject(adodb.recordset)connstr = Provider=Microsoft.ACE.OLEDB.12.0;Data Source=&DB_Path&;Persist Securit

5、y Info=False;ComMark=Check_Mark()sql= select DB_name,User_count from Mail_DBStore where E_name like %&ComMark&% order by User_count ASCmsgbox sqladocon.open sql,connstr,1,1If adocon.eof thenmsgbox 未查到该企业邮箱所属DB!Wscript.quitElsestr_DB=Trim(adocon(0)str_count=Trim(adocon(1)End if Int_str=CInt(str_count

6、)adocon.closeif Int_str 500 thenmsgbox 企业所属所有DB中邮箱个数均超过500Wscript.quitElsepp=Int_str+Ubound(User_list)+1Chsql= update Mail_DBStore set User_count= &pp& Where DB_name= &str_DB&adocon.open Chsql,connstr,2,2End ifFor i=0 To Ubound(User_list)show_Str= Enable-Mailbox -identity &Trim(User_list(i)& -Databa

7、se &str_DB& |Get-Mailbox |select name,windowsemailaddress,Database&vbCrLfW_Data.Write show_StrNextinsert_DB= insert into Hxy_Opt_Mark values(&i&,&ComMark&,1,&now()&);adocon.open insert_DB,connstr,1,1msgbox i&条记录已处理!End Function*核查用户*Function Check_User()set adocon=Createobject(adodb.recordset)connst

8、r = Provider=Microsoft.ACE.OLEDB.12.0;Data Source=&DB_Path&;Persist Security Info=False;ComMark=Check_Mark()User_list=Get_user()strSearchAttribute = sAMAccountNameFor i=0 To Ubound(User_list)Re_user=Search_User(strSearchAttribute,User_list(i)If Re_user= None Then show_Str=User_list(i)&不存在该用户ElseSet

9、objUser=GetObject(Re_user)show_Str=objUser.displaynameEnd ifW_Data.Write show_Str&vbCrLfNextinsert_DB= insert into Hxy_Opt_Mark values(&i&,&ComMark&,2,&now()&);adocon.open insert_DB,connstr,1,1msgbox i&条记录已处理!End Function*创建用户*Function Create_User()set adocon=Createobject(adodb.recordset)connstr = P

10、rovider=Microsoft.ACE.OLEDB.12.0;Data Source=&DB_Path&;Persist Security Info=False;Set objShell = CreateObject(Wscript.Shell) strPath = Wscript.ScriptFullNameSet objFile = fso.GetFile(strPath) strPath = fso.GetParentFolderName(objFile)Set objExcel = CreateObject(Excel.Application)Set objWorkbook = o

11、bjExcel.Workbooks.Open(strPath&users.xlsx)PPoint=InStrRev(objExcel.Cells(2, 1).Value,.)If PPoint 0 thenComMark=Right(objExcel.Cells(2, 1).Value,Len(objExcel.Cells(2, 1).Value)-InStrRev(objExcel.Cells(2, 1).Value,.)elseComMark=headEnd ifSet objOU =GetObject(LDAP:/ou=lastimp,dc=sinopec,dc=ad)intRow =

12、2Do Until objExcel.Cells(intRow,1).Value = SamAcc=Trim(objExcel.Cells(intRow, 1).Value)strSearchAttribute = sAMAccountNameIsNumber=Search_User(strSearchAttribute,SamAcc)If IsNumber= None ThenSet objUser = objOU.Create(User, cn=&SamAcc)objUser.sAMAccountName =SamAccobjUser.userPrincipalName=SamAcc&objUser.GivenName =objExcel.Cells(intRow, 4).ValueobjUser.SN = objExcel.Cells(intRow, 3).V

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 商业/管理/HR > 管理学资料

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号