none
Log Password change results of VBscript RRS feed

  • Question

  • I am using a batch file to execute a vbs file:

    @echo off
    cscript change_pw.vbs 

    I am changing the administrator password of computers in my OU (active directory) using the following script.

    Set objOU = GetObject("LDAP://OU=XXX,OU=XXX,DC=XXX,DC=XXX")
    objOU.Filter = Array("Computer")
    For Each objItem in objOU
        strComputer = objItem.CN
        Set objUser = GetObject("WinNT://" & strComputer & "/Administrator")
        objUser.SetPassword("abc123")
    MsgBox The password has changed successfully
          Next

    I am using the msgbox command for my test ou of about 5 computers and i get five prompts saying that it changed which i have tested and confirmed. However, once i do this on the production side i need to have results for all of the computers. Ideally my log file will have the host name of the computer and whether or not the password changed. Then based on that list i can target the failed machines directly once i determine what was wrong.

    I have used this command to create the log file but i dont know what command to use to pull the data i need. If there is a better way of doing this i am open to suggestions.

    Set ObjFSO = CreateObject("Scripting.FileSystemObject")
    Set objLog = objFSO.CreateTextFile("file path")

    I appreciate the help with this.

    Tuesday, November 24, 2015 2:34 PM

Answers

All replies