Executing script to change local admin password

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lonewolfbw
    New Member
    • Mar 2008
    • 2

    #1

    Executing script to change local admin password

    I have the following VBScript which I can execute from my workstation (I am a domain admin), in order to change the local computer's administrator password. However, I am noticing an oddity.

    First, the script:
    ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~

    Set objOU = GetObject("LDAP ://OU=test, DC=mycompany, DC=com")
    objOU.Filter = Array("Computer ")

    For Each objItem in objOU
    strComputer = objItem.CN
    Set objUser = GetObject("WinN T://" & strComputer & "/Administrator")
    objUser.SetPass word("InsertPas swordHere")
    Next

    ~~~~~~~~~~~~~~~ ~~~~~~~~

    Now, I created the test OU last week, and I can run this script on it today just fine.

    Today, about and hour and a half ago, I created another OU called Test2. I run the same script, with Test2 as the OU.. and the following error comes up:

    _______________ ____________
    ---------------------------
    Windows Script Host
    ---------------------------
    Script: D:\Documents and Settings\brianw \Desktop\Copy of Change Local Admin Password.vbs
    Line: 6
    Char: 5
    Error: The network path was not found.
    Code: 80070035
    Source: (null)

    ---------------------------
    OK
    ---------------------------

    Now, the only difference between these two OUs is that one was created last week, the other less than two hours ago. Is there some replication issue that could be going on here that I'm not aware of? I can't see why this error would occur for one OU but not the one right next to it, when they are named properly in the script.
  • lonewolfbw
    New Member
    • Mar 2008
    • 2

    #2
    Originally posted by lonewolfbw
    Now, the only difference between these two OUs is that one was created last week, the other less than two hours ago. Is there some replication issue that could be going on here that I'm not aware of? I can't see why this error would occur for one OU but not the one right next to it, when they are named properly in the script.
    Now I believe I have identified the problem. I tested several more times, and the error occurs when one or more of the computers whose objects are in the OU are *not* turned on.

    Test 1: I created the OU, moved my PC's object into it. Script ran successfully.
    Test 2: I moved a second PC object into that OU, said PC being active at the time. Script ran successfully.
    Test 3: I shut down the second PC. Then ran the script: the script failed as per above.

    So my question becomes - what do I need to adjust to make this script work if some of the Computer objects in the OU aren't necessarily turned on at the time? I'm aware they would not have their password changed, but this seems to prevent the script from functioning at all.

    Comment

    Working...