logfilepath path to share newpass ssw0rd Set WshNetwork WScript Create

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
logfilepath="\\path\to\share\"
newpass="P@ssw0rd"
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & WshNetwork.ComputerName & "\root\cimv2")
logfilename=logfilepath & WshNetwork.ComputerName & ".txt"
rem msgbox (logfilename)
Set colSystemUsers = objWMIService.ExecQuery("Select * from Win32_UserAccount")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(logfilename,2,True)
For Each objSystemUser in colSystemUsers
objFile.WriteLine "Working " & objSystemUser.Name
Set objUser = GetObject("WinNT://" & WshNetwork.ComputerName & "/" & objSystemUser.Name & ",user")
Call objUser.SetPassword(newpass)
objFile.WriteLine "OK"
Next
objFile.Close