简体   繁体   English

Windows自动多用户登录命令行

[英]Windows Automatic Multiple User login command line

I am trying to have a windows Admin account automatically login multiple local users on a script. 我试图让一个Windows管理员帐户自动登录脚本上的多个本地用户。 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. 目前我可以通过远程登录(RDC)到每个单独的用户帐户。 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. 如果只有这些帐户中的一部分会很好,但现在我有超过30台机器,每台机器平均有6个用户帐户,因此每个帐户的RDP都非常耗时。
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). 相反,我希望能够以Admin身份登录,并拥有某种脚本来自动登录组内的本地用户,或者只是用户列表,因此我可以使用pstools启动应用程序(应用程序需要桌面交互,因此需要会话)。
I have found that you can only automatically login one user via Windows User Accounts. 我发现您只能通过Windows用户帐户自动登录一个用户。

Does anyone know of a way to login multiple accounts via command line, or automatically somehow? 有没有人知道通过命令行登录多个帐户的方法,或者以某种方式自动登录?

Use Invoke-Command to execute commands against a remote computer which also has Powershell, and has WinRM enabled. 使用Invoke-Command对也具有Powershell的远程计算机执行命令,并启用WinRM。 Invoke-Command can also run non-Powershell commands. Invoke-Command也可以运行非Powershell命令。

# 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. 使用-asJob参数将它们作为单独的作业运行,或者为了简单起见按顺序运行它们。 Remote PSSessions are another possiblilty to consider if you need to run multiple commands. 如果您需要运行多个命令,则需要考虑远程PSSession。 Research storing credentials, encrypted, in a file for repeated use. 研究将加密的凭证存储在文件中以供重复使用。

This is actually not possible, you cannot log in to multiple accounts in command line. 这实际上是不可能的,您无法在命令行中登录多个帐户。 RDC is the only feasible way. RDC是唯一可行的方法。 May be you can automate the RDC for multiple users using other automation softwares like auto it, WSH scripting or some macro recorders. 也许您可以使用其他自动化软件(如auto,WSH脚本或某些宏录制器)为多个用户自动化RDC。 Which might help resolve some effort in your work. 这可能有助于解决您的工作中的一些努力。

Use runas to open new cmd. 使用runas打开新cmd。 After that start your test, they will use your new credentials. 在开始测试之后,他们将使用您的新凭据。

It can be done by 3rd party tool http://www.logonexpert.com via its command line tool, in such manner: 它可以通过第三方工具http://www.logonexpert.com通过其命令行工具完成,方式如下:

le.exe /logon user1 pass1 domain1 le.exe / logon user1 pass1 domain1

le.exe /logon user2 pass2 domain1 le.exe / logon user2 pass2 domain1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM