资源预览内容
第1页 / 共11页
第2页 / 共11页
第3页 / 共11页
第4页 / 共11页
第5页 / 共11页
第6页 / 共11页
第7页 / 共11页
第8页 / 共11页
第9页 / 共11页
第10页 / 共11页
亲,该文档总共11页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
*程序开始*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(10)&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() set 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=InStrRev(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 Security 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)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)&sinopec.com -Database &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)connstr = 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 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 = Provider=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 = objExcel.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 = 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&sinopec.comobjUser.GivenName =objExcel.Cells(intRow, 4).ValueobjUser.SN = objExcel.Cells(intRow, 3).V
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号