Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Automatic Multiple User login command line

I am trying to have a windows Admin account automatically login multiple local users on a script. The idea is to run a set of applications (tests) in each user session.
Currently I am able to do so by loggin in remotely (RDC) to each of the individual user accounts. This would be fine if there were just a few of these accounts, but now I have upwards of 30 machines with an average of 6 user accounts each so RDPing to each is extremely time consuming.
Instead, I'd like to be able to login as the Admin, and have some sort of script to automatically login the local users within a group, or just a list of users, so I can start the applications using pstools (the applications require desktop interaction, so a session is required).
I have found that you can only automatically login one user via Windows User Accounts.

Does anyone know of a way to login multiple accounts via command line, or automatically somehow?

like image 310
Farlan Avatar asked Mar 04 '13 17:03

Farlan


1 Answers

Use Invoke-Command to execute commands against a remote computer which also has Powershell, and has WinRM enabled. Invoke-Command can also run non-Powershell commands.

# users stored in csv with "username, password" format
foreach ($user in $userlist) {
    Invoke-Command "runas /profile /credentials $creds /user:$user.username /password:$user.password *executable*
}

Use the -asJob parameter to run them as separate jobs, or run them in sequence for simplicity. Remote PSSessions are another possiblilty to consider if you need to run multiple commands. Research storing credentials, encrypted, in a file for repeated use.

like image 64
Jeter-work Avatar answered Nov 11 '22 22:11

Jeter-work