脚本修改域内本地管理员密码
2012-07-17 08:41
417 查看
一台一台的修改域内计算机本地管理员密码不太现实,在没有Configuration manager这些工具的情况下,使用脚本来修改本地密码也颇为方便:
需要在远端计算机上关闭防火墙,至少是打开远程管理的端口135等,具体用TCPVIEW检测一下吧。
'Script for change the local administrator password On Error Resume Next Set objDictionary = CreateObject("Scripting.Dictionary") i=0 passwd="password1" call ChangePWD("OU=ou1,OU=ou2,DC=dc1,DC=cn",passwd) Wscript.echo "Finished!" If objDictionary.Count>0 Then call logError(objDictionary) '-----------------End of main program-------------------- Sub LogError(objDictionary) Const ForReading = 1, ForWriting = 2, ForAppending = 8 APP_ERROR_LOG = "chadminpwd.log" Set fsoSysObj = CreateObject("Scripting.FileSystemObject") Set oshell=createobject("wscript.shell") On Error Resume Next Set filFile = fsoSysObj.GetFile(APP_ERROR_LOG) If Err <> 0 Then Set filFile = fsoSysObj.CreateTextFile(APP_ERROR_LOG) End If On Error GoTo 0 ' Open file as text stream for reading. Set txsStream = filFile.OpenAsTextStream(ForAppending) With txsStream .WriteLine Now & " - Failed to change kbadmin on these computers:" For Each strComputer in objDictionary.Items .WriteLine strComputer Next .WriteBlankLines 1 .Close End With LogErrorEnd: Exit Sub End Sub 'The subroutine used for search the computers in the unit and 'change all the local administrator password sub ChangePWD(ouname,passwd) On Error Resume Next set ObjOU = GetObject("LDAP://" & ouname) ObjOU.Filter = Array("Computer") For Each ObjComp in ObjOU strComputer = Right(ObjComp.Name,Len(ObjComp.Name)-3) 'MsgBox strComputer & VbCrLf & ObjComp.OperatingSystem Set objUser = GetObject("WinNT://" & strComputer & "/administrator, user") If Err <> 0 Then Wscript.Echo strComputer & " - Failed!!" '& VbCrLf & Err.Number & " -- " & Err.Description i=i+1 objDictionary.Add i,strComputer Err.Clear Else objUser.SetPassword passwd objUser.SetInfo 'MsgBox strComputer & " has been successfully processed!" WScript.Echo strComputer & " - OK!" End If Next end sub
需要在远端计算机上关闭防火墙,至少是打开远程管理的端口135等,具体用TCPVIEW检测一下吧。
相关文章推荐
- 一种简单的修改所有域内本地管理员密码,及加某个帐号至本地管理员组的方法
- 轻松统一修改域内所有计算机(或者指定OU内的计算机)本地管理员密码
- 修改本地管理员密码的脚本
- Windows脚本系列之三——使用脚本批量修改本地管理员密码
- 更改域内客户机本地管理员密码vbs脚本--收藏
- 用pspasswd批量修改域内计算机本地管理员密码
- 修改本地管理员密码脚本
- 一种简单的修改所有域内本地管理员密码,及加某个帐号至本地管理员组的方法
- 如何在域环境使用脚本批量更改本地管理员密码
- 在域环境使用脚本批量更改客户机本地管理员密码
- 域环境通过powershell 远程修改本地管理员账户密码
- 如何在域环境使用脚本批量更改本地管理员密码
- 灵活使用组策略:[2]修改本地管理员密码
- 在域中更改本地管理员密码的VBS脚本
- 使用组策略统一修改客户端本地管理员密码
- 组策略 之 统一修改域中计算机的本地管理员账户和密码和受限制组
- 利用域控设置启动脚本统一更改客户端administrator密码和添加客户端本地管理员账号
- 利用域控设置启动脚本统一更改客户端administrator密码和添加客户端本地管理员账号
- 如何在域环境使用脚本批量更改客户端本地管理员密码
- 如何在域环境使用脚本批量更改本地管理员密码