Change local administrator password of each machine on startup to the one set in the script.

bsharath
bsharath used Ask the Experts™
on
Hi,

Change local administrator password of each machine on startup to the one set in the script.
After the change update a Log file on the change status.

Regards
Sharath
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
sure...user NET USER
http://support.microsoft.com/kb/149427
@ECHO OFF
SET LOGPATH=\\servername\serverfolder
SET LOGNAME=AdminUpdates.log
 
NET USER ADMINISTRATOR NewPassword
ECHO Changed Admin pass for %COMPUTERNAME% >> %LOGPATH%\%LOGNAME%
 
EXIT

Open in new window

Author

Commented:
Thanks Even when password fails to be set the log shows successful

I get this when i give a complex password

The password does not meet the password policy requirements. Check the minimum p
assword length, password complexity and password history requirements.

More help is available by typing NET HELPMSG 2245.

'*IPTglobal9' is not recognized as an internal or external command,
operable program or batch file.
Press any key to continue . . .

The password i am using to set is
ICT&*^IPTglobal9
are you on a domain? if so, add the /domain switch at the end. Also are you enclosing the password in quotes? You have a special character in there and I don't recall for sure, but I think it needs quotes.
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Author

Commented:
Like this?

NET USER ADMINISTRATOR "Domain\NewPassword"
Try this
NET USER ADMINISTRATOR "ICT&*^IPTglobal9" /domain

Open in new window

Author

Commented:
I get this

The request will be processed at a domain controller for domain DevGroup.co.uk.

The command completed successfully.

Press any key to continue . . .

Does it reset the pass on the DC or local administrator

Commented:
I think adding the /domain switch at the end actually changes the domain admin password no?

I had to do the same thing at one point, try this:
strComputer = "."
Set objUser = GetObject("WinNT://" & strComputer & "/Administrator")
objUser.SetPassword("ICT&*^IPTglobal9")
If Err.Number <> 0 Then
	WScript.Echo "Error: " & Err.Description
Else
	WScript.Echo "Changed Password on: " & strComputer
End If

Open in new window

Author

Commented:
I am sure it did change the domain admin password...

Commented:
you should be able to run that vbscript above, just don't run it on a DC because there is no local admin for a DC and it will reset the domain admin account
Ya, I never use it in a domain environment so... not sure. That VBScript looks like it should be what you need. So, did you try the NET USER command with quotes?
NET USER ADMINISTRATOR "ICT&*^IPTglobal9"

Open in new window

Author

Commented:
SaLus
Script is fine can i get a log that saves the machinename_Date of the password reset into a UNC path

TheNautican
Can i get it with the UNC storing option for logs
Commented:

Const ForWriting = 2
Dim objFSO
Dim strComputer
Dim objUser
Dim logFile
Dim ResetTime
 
' Generates Date i.e. 20091024
ResetTime = Year(Date) & Month(Date) & Day(Date)
 
' Gets computer name
strComputer = "."
 
' Creates file  \\myserver\myshare\MyComputer_20091024.log
strUNCFolder = "\\YOUR SERVER\YOUR FOLDER\" & strComputer & "_" & ResetTime & ".log"
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set logFile = objFSO.OpenTextFile(strUNCFolder,ForWriting,True)
 
Set objUser = GetObject("WinNT://" & strComputer & "/Administrator")
objUser.SetPassword("ICT&*^IPTglobal9")
If Err.Number <> 0 Then
	logFile.WriteLine strComputer & " had an error: " & Err.Description
Else
	logFile.WriteLine "Changed password for computer: " & strComputer
End If
 
logFile.Close

Open in new window

The VBScript gives you the error checking you may need/want.
@ECHO OFF
SET LOGPATH=\\servername\serverfolder
SET LOGNAME=AdminUpdates.log
 
NET USER ADMINISTRATOR "ICT&*^IPTglobal9"
ECHO Changed Admin pass for %COMPUTERNAME% >> %LOGPATH%\%LOGNAME%
 
EXIT

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial