Question Locked

Script to change local admin

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi,

I'm very new to scripting. I have this vb script to change the local admin password on machines and it works great. However, I have to specify which OU the workstations are in. I have workstations in multiple OU's though. How can specify the multiple OU's? Here's the script:

Set objOU = GetObject("LDAP://OU=test this, OU=Workstations, DC=domain, DC=com")
objOU.Filter = Array("Computer")

For Each objItem in objOU
strComputer = objItem.CN
Set objUser = GetObject("WinNT://" & strComputer & "/Administrator")
objUser.SetPassword("password")
Next

Thanks very much for any help.

2 replies

by cbernhardt

All that you need in 4th line to write a NetBIOS-name of your domain, save this file with a name "adminpasschange.vbs". Then - double click the mouse.
After performance in the same directory where " adminpasschange.vbs" file Rezult.log will appear there will be a change of PASSWORD of registration records Administrator.

On Error Resume Next
Set file_object = CreateObject("Scripting.FileSystemObject")
Set list = file_object.CreateTextFile("./Rezult.log")
domain = "My_domain" '********
Set container_comp = GetObject("WinNT://" & domain)
container_comp.Filter = Array("Computer")
For Each comp In container_comp
comp_in_domain = comp.Name
Set container_user = GetObject("WinNT://" & my_domain & "\" & comp_in_domain)
container_user.Filter = Array("User") ' Good
For Each user In container_user
If user.Name="Administrator" Then
list.Write comp_in_domain & " ---"& user.Name & vbCrLf
user.SetPassword = "PASSWORD"
End If
Next
Set container_user = Nothing
Next
list.Close
WScript.Quit(0) ' Exit

This discussion is closed to new replies.