[Info] VBS para cambiar password's de dominio

09/10/2004 - 18:25 por Javier Inglés [MS MVP] | Informe spam
http://techrepublic.com.com/5100-62...98818.html



'
-

' Developer: Randy Barger (randy_barger@yahoo.com)

' Last Modified: February 23, 2004

' Description: This script will read in a list of computer account names

' from a file (created manually or by exporting a list from an

' OU/container using ADU&C). Each computer name must be the

' first item on each line of the file; anything after the

' computer name will be ignored. The script will attempt to

' change the local iberoot account password for each

' computer. Note: The first line of the input file is

' assumed to be a header line.

'
-



'
-

' Initialization - Declare variables

'
-



Dim fsoIn, fsoOut

Dim inFile, outFile

Dim arrComputerNames

Dim objUser

Dim strComputer

Dim newPassword

Dim ErrorOccurred

Const ForReading = 1

Const ForWriting = 2

Const ForAppending = 8

Const inFilename = "servers.txt"

Const outFilename = "ChangePwdServers.log"



'
-

' Main script

'
-

On Error Resume Next

ErrorOccurred = False



' Insert WARNING here...

Msgbox ("WARNING: This script will change the local iberoot password for
every " & _

"computer listed in SERVERS.TXT. If any services are running with the local
" & _

"iberoot credentials, those services must be updated, or they won't " & _

"start on the next boot. For this script to work, you must have
administrative " & _

"privileges on all of the remote computers you are changing the password
for.")



' Get new password

newPassword = Inputbox ("Please enter the new password.")



' Open the input file and skip the header line

Set fsoIn = CreateObject("scripting.filesystemobject")

Set inFile = fsoIn.OpenTextFile(inFilename, ForReading, True)

inFile.Skipline



' Open the log file (append mode) and timestamp the entry

Set fsoOut = CreateObject("scripting.filesystemobject")

Set outFile = fsoOut.OpenTextFile(outFilename, ForAppending, True)

outFile.writeline (Now & vbTab & "Starting script...")



While Not inFile.AtEndOfStream

arrComputerNames = Split(inFile.Readline, vbTab, -1, 1)

' arrComputerNames(0) contains the computer name

strComputer = arrComputerNames(0)



' Connect to the computer\iberoot account

Set objUser = GetObject("WinNT://" & strComputer & "/iberoot, user")

If Err.Number <> 0 Then

outFile.writeline Now & vbTab & "Error connecting to " & strComputer & "
" & Err.Description

Err.Clear

ErrorOccurred = True

Else

' Set the password for the account

objUser.SetPassword newPassword

objUser.SetInfo

If Err.Number <> 0 Then

outFile.writeline Now & vbTab & "Error setting password for " & strComputer
& _

"\iberoot" & " " & Err.Description

Err.Clear

ErrorOccurred = True

Else

outFile.writeline (Now & vbTab & "Password set for " & strComputer &
"\iberoot")

End If

End If

Wend



' Clean up the environment

outFile.writeline (Now & vbTab & "Ending script...")

inFile.close

outFile.close



If ErrorOccurred Then

msgbox "Script completed with errors. Please check the log file."

Else

MsgBox "Script completed successfully."

End If







Hay que exportar desde AD users and computers la lista de máquinas y guardar
el archivo como "servers.txt"


Salu2!!!
Javier Inglés, MS-MVP
http://mvp.support.microsoft.com/default.aspx

Troll's reconocidos y asíduos de estos foros:
Ille Corvus
Maximilian Heel
Juan-Luis (el tonto del dedo)
Juvenal
http://es.wikipedia.org/wiki/Troll

e-m@il:jingles@NOSPAMmvps.org
<<<QUITAR "NOSPAM" PARA MANDAR MAIL>>>

Este mensaje se proporciona "como está" sin garantías de ninguna clase, y no
otorga ningún derecho
 

Leer las respuestas

#1 Ille Corvus
12/10/2004 - 21:37 | Informe spam
"Javier Inglés [MS MVP]" escribio en
mensaje :

http://techrepublic.com.com/5100-62...98818.html



'
-

' Developer: Randy Barger ()

' Last Modified: February 23, 2004

' Description: This script will read in a list of computer account names

' from a file (created manually or by exporting a list from an

' OU/container using ADU&C). Each computer name must be the

' first item on each line of the file; anything after the

' computer name will be ignored. The script will attempt to

' change the local iberoot account password for each

' computer. Note: The first line of the input file is

' assumed to be a header line.

'
-



'
-

' Initialization - Declare variables

'
-



Dim fsoIn, fsoOut

Dim inFile, outFile

Dim arrComputerNames

Dim objUser

Dim strComputer

Dim newPassword

Dim ErrorOccurred

Const ForReading = 1

Const ForWriting = 2

Const ForAppending = 8

Const inFilename = "servers.txt"

Const outFilename = "ChangePwdServers.log"



'
-

' Main script

'
-

On Error Resume Next

ErrorOccurred = False



' Insert WARNING here...

Msgbox ("WARNING: This script will change the local iberoot password for
every " & _

"computer listed in SERVERS.TXT. If any services are running with the local
" & _

"iberoot credentials, those services must be updated, or they won't " & _

"start on the next boot. For this script to work, you must have
administrative " & _

"privileges on all of the remote computers you are changing the password
for.")



' Get new password

newPassword = Inputbox ("Please enter the new password.")



' Open the input file and skip the header line

Set fsoIn = CreateObject("scripting.filesystemobject")

Set inFile = fsoIn.OpenTextFile(inFilename, ForReading, True)

inFile.Skipline



' Open the log file (append mode) and timestamp the entry

Set fsoOut = CreateObject("scripting.filesystemobject")

Set outFile = fsoOut.OpenTextFile(outFilename, ForAppending, True)

outFile.writeline (Now & vbTab & "Starting script...")



While Not inFile.AtEndOfStream

arrComputerNames = Split(inFile.Readline, vbTab, -1, 1)

' arrComputerNames(0) contains the computer name

strComputer = arrComputerNames(0)



' Connect to the computer\iberoot account

Set objUser = GetObject("WinNT://" & strComputer & "/iberoot, user")

If Err.Number <> 0 Then

outFile.writeline Now & vbTab & "Error connecting to " & strComputer & "
" & Err.Description

Err.Clear

ErrorOccurred = True

Else

' Set the password for the account

objUser.SetPassword newPassword

objUser.SetInfo

If Err.Number <> 0 Then

outFile.writeline Now & vbTab & "Error setting password for " & strComputer
& _

"\iberoot" & " " & Err.Description

Err.Clear

ErrorOccurred = True

Else

outFile.writeline (Now & vbTab & "Password set for " & strComputer &
"\iberoot")

End If

End If

Wend



' Clean up the environment

outFile.writeline (Now & vbTab & "Ending script...")

inFile.close

outFile.close



If ErrorOccurred Then

msgbox "Script completed with errors. Please check the log file."

Else

MsgBox "Script completed successfully."

End If







Hay que exportar desde AD users and computers la lista de máquinas y guardar
el archivo como "servers.txt"



gracias


Filtrado (Kill-File Global):
tella llop, jm (Desde 2003.10.25)

Preguntas similares