문제

We have thousand of Windows server in our network. For some kind of work we need to log in on 100+ servers. We are doing it manually. Entering server name and giving credentials. Is it possible to create a batch file/script so, this work can be automated. Like we simply create a text file or csv and run the script. Script can open mstsc session and put credential in the mstsc. We can define username and password in the script.

도움이 되었습니까?

해결책

Consider using remote desktop manager - remotedesktopmanager.com, it allows you to create several predefined remote desktopts, save different rdp settings for them, and switch between desktops in more convenient way.

Also when you connect via usual mstsc, you can save it as a separate rdp file and ask it to remember credentials when conecting first time, and just store separate rdp files that way.

다른 팁

This will launch Remote Desktop for all of the servers, but you still have to input credentials. There are ways you can implement Single Sign On but it only applies to Windows 2008 and 2008 R2. mstsc doesn't have any switches for username or password, so it can't be scripted. There isn't even a hack for it since you can't use sendkeys to a remote desktop window.

Create a file with server names one per line and put it in the same directory as the batch file.

Create the following batch file

@echo off
setlocal

cd /d %~dp0
set file=Servers.txt

for /f %%a in (%file%) do (
    echo mstsc /v:%%a 
)

Remove the echo to actually launch Remote Desktop. At least it takes 1 step out of the equation and you can always save your credentials so it doesn't prompt for them which is more secure than putting them in a file.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top