VanDyke Software

Tips

Index

VShell® Server Automation – Change Password

This is the first in a series of tips that will outline how to use VShell to automate common administrative tasks.

This tip will describe how to change the local administrator password without having to physically go to every machine. VShell must be installed on all machines on which the password is to be changed.

Fortunately, the Windows command line allows you to perform almost all of the Windows tasks that you need to administer the system. The syntax in most cases is straightforward and easy to learn, and remote command-line administration is much more efficient than Remote Desktop because only a few bytes are transmitted and the process can be automated for multiple machines.

The Windows command shell is a powerful environment and contains a strong complement of Win32 console utilities to support it, including "net config" and "net user". Many of the Windows integrated administrative facilities are grouped under the "net" command. Typing "net" at the command line will print out a list of these commands. Details about the use of any "net" command are available by typing:

 net <command> /?

Changing the local administrator's password can be accomplished by executing the following command on each system:

 net user <username> <new_password>

The command will be launched using the remote execute capability of an SSH2 connection made to each target machine's VShell service.

Running the remote command can be accomplished in a number of ways, depending on the SSH client you are using. For example, VanDyke Software's vsh utility can be used to execute the change password operation by adding the command after the login/host information:

 vsh -pw P4$$w0rd local-admin@host.domain "net user local-admin N3wPa$$w0rD"

Another way to run the remote command would be to use VanDyke Software's VRALib COM interface. The VRALib API allows scripting of SSH2 connections and provides remote execution through the "Connection" and "Exec" objects. For example, the sequence of PowerShell commands use the VRALib COM API to perform a password change operation on a remote machine:

PS> $connection = New-Object -com vralib.connection
PS> $connection.Hostname = "192.168.232.163"
PS> $connection.Username = "local-admin"
PS> $connection.Password = 'P4$$w0rd'
PS> $connection.AutoAcceptHostKey = 1
PS> $connection.Connect()
PS> $connection.IsConnected
True
PS> $exec = $connection.Exec('net user local-admin N3wP4$$w0rd')
PS> $exec.ExitCode
0
PS> $exec.StdOut.ReadAll()
The command completed successfully.
PS> $connection.Disconnect()

Please see the VShell for Windows or SecureCRT for Windows help files for more information about using VRALib.

VanDyke Software uses cookies to give you the best online experience. Before continuing to use this site, please confirm that you agree to our use of cookies. Please see our Cookie Usage for details.