Execute RDP connection on multiple server - windows

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.

Related

Script to Log into several user accounts

We manage several laptops that are used for emergency situations and thus are rarely used (knock on wood).
When we start up these laptops periodically to run windows updates, we also sign in with several user accounts for each laptop in order to keep the profile up to date.
Is there a way to automate the logging in of each account with a script?
For example, I could log in as administrator, run the script and the laptop would do the following:
Log out my administrator account,
sign in with useraccount 1, log out
sign in with useraccount 2, log out
sign in with useraccount 3, log out
I havent had much luck in googling this type of thing and was hoping someone here might have an idea.
I simply cant find a script that logs in with a user account.
The closest I can find is recommending auto signin but that only applies to one account and not what I need for this task.
Globally, you can't do that: it would break security if you were allowed to interact, programmatically, with the login screen.
IF it's possible, I would look to a way to do the login to remote machine through either Telnet (not recommended! but can be done with standard Windows tools) or SSH (will need a SSH server). If you can do the upgrade this way, then you're saved, in particular with SSH because you can avoid passwords' sharing through key exchange - probably won't work with domain accounts, however, but local accounts will be fine.
Otherwise, if you require to really open a Windows session, best you can do, IF your configuration allows it AND if it works (regarding the profile's update) is to connect through RDP (Remote Desktop) to each laptop, with each login.
You'll need to establish a RDP connection to each laptop from a "pilot" PC, save each connexion individually within a .rdp file, saving password inside the connection file.
Then, you can launch the connection with the command mstsc <machine+account>.rdp to establish a connection. A bit later, you can kill the connection (with either taskkill or through a pilot process / tool, I would use AutoIt for this preferably).
If password saving is an issue, then each employee should have its own set of RDP files. Through something like Autoit, in particular, you can input the password once, and fill automatically each password prompt.
The tricky part would be to know when it's time to close the remote desktop. I would try to automatically execute a command to distant computer that would reboot it once done, so your remote desktop would close automatically.
Anyway, it will be a real gas plant to implement all this in a smooth process...

how to log off from samba server on windows 10

I have access to a Samba server using a username and password. To logging the server on windows 10, I put its IP address on the RUN and then input my username and password. Then I can access the data stored in the server normally. However, I don't know how to log off (or Sign out) from that server.
I followed this tutorial about how to access the server, but it does not mention the log off process. I need to log-off and log-in again with my username and password whenever I need to access the server.
Can anyone help?
"Try to restart your workstation".
TL;DR
Open CMD, type NET USE X: /DELETE or NET USE \\SERVER\SHARENAME /DELETE
where X: is your drive and \SERVER\SHARENAME your fully qualified share name.
Step by Step
View all network connections:
NET USE
Example Output:
Status Local Remote Network
--------------------------------------------------------------------------------
OK \\name\IPC$ Microsoft Windows Network
OK \\name2\folder Microsoft Windows Network
Using the Remote name, we can disconnect using on of the following statements, depending on which one we want to disconnect from:
net use \\name /delete
OR
net use \\name2\folder /delete
Example Output: (given the above \name\IPC being connected))
Net use \\name /delete
\\name was deleted successfully.
Another way, to disconnect from every share is to execute net use * /delete. This will disconnect every Network share you're currently connected to. This is still quicker than logging off and back on.
Bonus: make a script to do it
If you want to create an icon to automatically disconnect all network shares (using a GUI method), you can do the following:
Right-click on a blank area of the folder you want to add the shortcut to.
Point to New->Shortcut and click.
Type net use * /delete /y for the Command, then click Next.
Give it a name, and click Finish.
You can also specify a certain network share, if known in advance, and use that one instead. Using the /y automatically select the yes option in the command.
open notepad:
#echo off
::Disconnect user
net use * /delete /y
msg * /time:5 "You have been successfully Disconnected"
Copy paste save as a bat (file Extention " *.bat ", create a shortcut edit the shortcut to an icon of your choosing...
upon double click, the command will be run and a gui popup box will say the message and go away in 5 seconds or wait 5 seconds till appearing...
we use this quite a bit at work :)

pscp works for one account but does not work for another

I have two accounts A, B both registered on the windows server 2008 R2.
There is a script in which I use pscp module of putty to transfer files from the server.
Problem being that the command runs successfully using user account A but gets stuck using account B. The command does not complete using user account B
I have to manually terminate it.
Both accounts have the below privilege in group policy and computer management.
Administrator
Logon as a batch
Replace process level token
Please help
I figured out the problem. When we use pscp alone on command prompt , this is the prompt we get
The server's host key is not cached in the registry. You have no
guarantee that the server is the computer you think it is. The
server's rsa2 key fingerprint is: ssh-rsa 1024
cc:78:13:a3:68:a6:59:7e:b8:23:2d:13:3e:66:9b:b9 If you trust this
host, enter "y" to add the key to PuTTY's cache and carry on
connecting. If you want to carry on connecting just once, without
adding the key to the cache, enter "n". If you do not trust this host,
press Return to abandon the connection. Store key in cache? (y/n)
Connection abandoned.
We need to press y/n and the command shall thereafter proceed.
While this command was running in the script , the prompt was not getting any input from the user and was therefore never ending.
To mitigate this
one can do something like this
How to pass value to psftp prompt

How to download from FTP server

So I'm trying to make a "launcher" in visual basic. This launcher contains login forms (username/password). I have a Filezilla server up and 2 accounts. I'd like to connect with the server and download files in the background as not to disrupt work. I'm not much of a coder, but I tried to tie this up with "winSCP", what I did was only launch and connect to the server, but the user still has to enter username and password, which was entered before (with the login form).
Also how would I change the "USER" part, like with batch files when you can use "%username%" instead of actual username?
If ComboBox1.Text = "Server EU #1" Then
Process.Start("C:\Users\USER\Desktop\winscp573\WinSCP.exe", "ftp:[server IP]")
End If
If at all possible I'd like to avoid using other programs and keep it as simple as possible.
TL;DR
Login with visual studio to filezilla server (FTP), not using other programs
upload files from main computer to the user (automatically starts uploading CERTAIN files/folders, everything running in the background as not to disrupt work, aka nothing popping up)
Change [USER] part of code so that it is always the correct user (like batch files use "%username%")
P.S.
maybe I could use windows build it FTP to connect and download?

Does anyone know how to issue a SUBMIT command to OpenVMS over an FTP session?

I am currently using windows telnet to submit files to the OpenVMS queue via a series of sendkeys/application waits through VBA. It works, up until the end-user shifts focus away from the telnet window. I would prefer to issue the SUBMITs using an FTP session, where I can script the commands into a batch file and shoot it across FTP. I was able to do something similar with IBM mainframes - through the quote site FTP command - setting the filetype=jes, followed by a JCL file that would be dropped into the work queue for immediate execution. I can't seem to find anything on the internet related to FTP, openVMS, and submit. I have tried using Quote submit/que=... but it does not recognize the command. (Submit works fine under telnet).
Maybe you can use Remote Shell Protocol (RSH) to execute a command in a remote node
You would need a rsh client on windows:
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/rsh.mspx?mfr=true
And also enable RSH service on VMS via TCPIP$CONFIG
(See OpenVMS documentation http://h71000.www7.hp.com/doc/index.html)
This works best with a VMS username dedicated to processing inbound FTP files. If you put in the LOGIN.COM for that username to detect it's a network connection and submit a batch job to look for the expected file, get exclusive access to it with retries (the FTP is done), and then process the file - That has worked for me.
The other option is to put a security ACL on the directory and make an audit listener - it will get file creates via a mailbox message. Then it can do similar: get exclusive access to the file being created and then process it.

Resources