→ 🚀What's New? Join Us for the Fall Product Launch! Register Now !

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Bert_D
Lansweeper Employee
Lansweeper Employee

Looks up the name of the Local Administrator and resets the password.

Rem: You need to add the password as a parameter.
Rem: If you do not add a password parameter, the password is default set to: !NewCompl3xP@ssword!

Rem: Copy the code below and save it as Reset_Local_Admin_Password.vbs at the {PackageShare}\Scripts folder


On Error Resume Next
strComputer = "."

Set oShell = CreateObject("WScript.Shell")
sUser = "Administrator"
sPwd = "!NewCompl3xP@ssword!"

Set Arg = WScript.Arguments
If Arg.Count > 0 Then
sPwd = Arg(0) 'Pass the password as parameter to the script
End if

'Get the administrator name
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_UserAccount Where LocalAccount = True")
For Each objItem in colItems
sidAdmin = objItem.SID
if trim(right(sidAdmin, 3)="500") and trim(left(sidAdmin,9)="S-1-5-21-") then

'Echo = echo & "Name: " & objItem.Name & vbcrlf
'Echo = echo & "SID: " & sidAdmin
sUser = objItem.Name
Set oUser = GetObject("WinNT://" & strComputer & "/" & sUser)

' Set the password
oUser.SetPassword sPwd
oUser.Setinfo

exit for
end if
Next
17 REPLIES 17
cNone
Engaged Sweeper
Hello,

Thanks for the script but I coludn't made it work. I can send commands via webui but this script isn't working and gives the browser configuration error. Default actions are working but not this one. Am I missing something?

Thanks in advance.
Florian_Eigsi
Engaged Sweeper III
Hi,

I just launch one command :

net user Administrateur YourPassword /active:yes


No vbs needed
Florian_Eigsi wrote:
Hi,

I just launch one command :

net user Administrateur YourPassword /active:yes


No vbs needed


I do something similar as when I joined this company the local admin password was set randomly on machines and not on others, it was a real hassle when we would get machines back having to bypass the login all the time.

So we pushed this out to every machine but also added it to our SOE.

net user administrator PASSWORD /active:yes
net accounts /MaxPWAge:UNLIMITED
net user Administrator /expires:never
REG ADD HKLM\Software\Lansweeper /v AdminAcctEnabled /t REG_DWORD /d 1

The last command is so we can report on those that have had the password set correctly, if not, we can re-deploy it via a scheduled report or some other means.
sreejith
Engaged Sweeper
Hi ,

How to rename user account
warlock1663
Engaged Sweeper
Hi,
I know this feed is pretty old but I hope someone sees this.

Can this be used on certain OU's or will it change every password in active directory?

Thanks
tmcmanus3385
Engaged Sweeper
gotcha. I"m new to scripts and didn't catch the original script looked the administrators name up. I thought it was changing the password for the account named Administrator. I will give this a try. thanks
Bert_D
Lansweeper Employee
Lansweeper Employee
I'm not sure what you are trying to do there...
If you know the name of the user you are trying to change, don't make it too hard on yourself


On Error Resume Next
strComputer = "."

Set oShell = CreateObject("WScript.Shell")
sUser = "scc2"
sPwd = "newpasswordhere"

Set oUser = GetObject("WinNT://" & strComputer & "/" & sUser)
oUser.SetPassword sPwd
oUser.Setinfo
tmcmanus3385
Engaged Sweeper
We have a local admin account named scc2 and its a local admin account. I'm trying to edit this script and use it to change the password for this account on all our computers on campus. I changed the password, username and sid where needed, but its not changing the scc2 password, but it does change the local Admin account's password. I thought that was strange considering the username changed in script. I changed the password and SID in script below for security reasons, but this is basically what I'm using. I"m rookie at scripts and could use the help. Any ideas on why its not changing the password for co-optech?

On Error Resume Next
strComputer = "."

Set oShell = CreateObject("WScript.Shell")
sUser = "scc2"
sPwd = "newpasswordhere"

Set Arg = WScript.Arguments
sPwd = Arg(0) 'Pass the password as parameter to the script

'Get the administrator name
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_UserAccount Where LocalAccount = True")
For Each objItem in colItems
sidAdmin = objItem.SID
if trim(right(sidssc2, 3)="1001") and trim(left(sidAdmin,9)="S-1-5-21-333333333-22222222-111111111-1001")

then

'Echo = echo & "Name: " & objItem.Name & vbcrlf
'Echo = echo & "SID: " & sidscc2
sUser = objItem.Name
Set oUser = GetObject("WinNT://" & strComputer & "/" & sUser)

' Set the password
oUser.SetPassword sPwd
oUser.Setinfo

exit for
end if
Bert_D
Lansweeper Employee
Lansweeper Employee
Yes that's possible, you will need to change the script a little to look up the hostname and add it to your password.