Windows server Active Directory (AD) Log on script for change local Administator password

1. Create *.vbs file as script below


'-----------------------------------------logon script--------------------------------
'Chang password local administrator save to *.vbs format
'-------------------------------------------------------------------------------------
On Error Resume Next

Dim objUser
Dim newPassword
Dim CompName
Dim WshShell
Dim WshEnv

'Set the Username & Password below
'------------------------------------------------------------------------------------------
LocalAdmin = "administrator"
newPassword = "Angsana@03"
'------------------------------------------------------------------------------------------

Set WshShell = CreateObject("WScript.Shell")
set WshEnv = WshShell.Environment("Process")
CompName = WshEnv("COMPUTERNAME")

' Connect to the computer\administrator account
Set objUser = GetObject("WinNT://" & CompName & "/" & LocalAdmin, user)

'Set the password for the account
objUser.SetPassword newPassword
objUser.SetInfo

' Clears up the environment
Set WshShell = nothing
Set WshEnv = nothing
Set objuser = nothing

msgbox "Local Account = " & LocalAdmin & " Password Changed Sucessfully"
'-----------------------------------------End Script--------------------------------------------

2. Add logon script to OU, That you want to change Administrator password.


Good luck .. Techtoy

ความคิดเห็น

บทความที่ได้รับความนิยม