3 Replies Latest reply on Mar 6, 2017 5:57 AM by Tombs

    Local Account Password Change

    Apprentice

      I have a script that I use in Provisioning to create a local admin account on each machine and it also sets the password that is passed from a template variable so it is completely hidden. What I need to do is create some way to update passwords on every PC in my environment. I can use a Provisioning template to do this so it only adds the account if it isnt there using the same script and sets the password in the same way from the variable but I can't do it so the output is hidden from the user, even if I use a delivery method that explicitly says hide user feedback. What I want to do is create a distribution package that calls my .VBS script but I need some way to pass the password to it. Below is the content of my .VBS script and the variable I use from Provisioning is var1.Does anyone know if this is possible or if there is another better way to do it? I know I could use the update local user password option but this only allows the creation of a scheduled task and this can't be made a policy so it's messy.

       

       

      'this section creates the new Tech2 account if it doesn't exist
      'var1 is passed to this program as an encrypted password thru LANDesk provisioning

      Dim ArgObj, var1
      Set ArgObj = WScript.Arguments

      var1 = ArgObj(0)

      QueryForUser("Tech2")

                      Set objNetwork = CreateObject("Wscript.Network")
                      strComputer = objNetwork.ComputerName
                      Set objComputer = GetObject("WinNT://" &strComputer)

                      Set colAccounts = GetObject("WinNT://" & strComputer & "")
                      Set objUser = colAccounts.Create("user", "Tech2")
                      objUser.SetPassword var1
                      objUser.Put "UserFlags", 65600 '
                      objUser.SetInfo

      'add to administrators group
                      Set objGroup = GetObject("WinNT://" & strComputer & "/Administrators,group")
                      Set objUser = GetObject("WinNT://" & strComputer & "/Tech2,user")
                      objGroup.Add(objUser.ADsPath)

                
      'this section just changes the password if the user exists

      Sub QueryForUser(strUserName)
          Set objlocal = GetObject("WinNT://.")
          objlocal.Filter = Array("user")
          For Each User In objlocal
              If lcase(User.Name) = lcase(strUserName) Then

                      strComputer = "."
                      Set objUser = GetObject("WinNT://" & strComputer & "/Tech2, user")
                      objUser.SetPassword var1
                      objUser.SetInfo

                  WScript.Quit
              End If   
          Next
      End Sub