VBS Script To Change The Local Administrator Password On A List Of Machines And Send The Results To Excel

 

This VBS script will allow you to change the local administrator password on the machines contained in a text file named MachineList.Txt. The script will prompt you for the password from an input dialog box rather than hard coding the password. The script will then write the machine name and whether or not the password was successfully changed to an excel spreadsheet.

 

VBS Script:

 

strNewPassword = InputBox ("Enter New Password")

 

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True

objExcel.Workbooks.Add

intRow = 2

 

objExcel.Cells(1, 1).Value = "Machine Name"

objExcel.Cells(1, 2).Value = "Password Changed"

 

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objTextFile = objFSO.OpenTextFile("MachineList.Txt")

Do Until objTextFile.AtEndOfStream

strComputer = objTextFile.ReadLine

On Error Resume Next

 

Set objUser = getobject("WinNT://" & strComputer & "/Administrator,User")

objUser.SetPassword strNewPassword

objUser.SetInfo

 

objExcel.Cells(intRow, 1).Value = UCase(strComputer)

If Err.Number <> 0 Then

objExcel.Cells(intRow, 2).Value = "No"

Err.Clear

Else

objExcel.Cells(intRow, 2).Value = "Yes"

End If

intRow = intRow + 1

Loop

 

objExcel.Range("A1:B1").Select

objExcel.Selection.Interior.ColorIndex = 19

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Cells.EntireColumn.AutoFit

 

MsgBox "Done"

 

Published Sunday, August 19, 2007 6:22 AM by dhite
Filed under:

Comments

# PowerShell script to change administrator password on a list of machines

Here is a PowerShell script to change local administrator (or any account interested) password on a list

Thursday, August 23, 2007 11:24 AM by Ying Li at myITforum.com