1

I am trying to import data from a remote server. My current approach is the create a script on the remote server, which is executed every time I log in using remote desktop. When I log in, a network share is mounted into the RDP session, and the script which is executed, copies a directory from the remote server to the mounted network share, thus making this directory locally available.

I want to automate this process, by creating a windows task. This task should log in a user in the remote server (RDP), and thus trigger the script execution. Is this a feasible method? Would it be possible to achieve this in another way?

  • How do you plan to store the credentials needed to make a connection? What privileges do those credentials have on the remote machine? – Vikas Gupta Nov 28 '14 at 9:16
  • I would create an remote.rdp file, and launch it from the script with the credentials saved. The user logging into the remove machine has enough right to execute xcopyand put the file into the mounted share. – Kiril Nov 28 '14 at 9:17
  • Is there a reason why you use a workaround? I would make it possible to connect to the other pc directly through a network share (in combination with VPN if required). Or use FTP if VPN is not available. – LPChip Nov 28 '14 at 11:01
  • The connection is established by VPN, and only port 3389 is allowed to be open in the firewall... – Kiril Dec 2 '14 at 12:28
1

Yes you can write a powershell script to do the needful and from task scheduler by adding action as "Program/Script: Powershell.exe" and argument should me your ps file location. Check the Microsoft link for detailed information on how to execute a powershell script in task scheduler.

Edited:

You can connect remote machine from poweshell using the command

Enter-PSSession -ComputerName computer_name

Steps to establish remote connection using power shell.

| improve this answer | |
  • Running the powershell script as a task is the easier part. I am trying to open RDP session using the script, or looking for an alternative approach. – Kiril Nov 28 '14 at 9:16
  • @Kiril, the post has been updated :) – Dave Nov 28 '14 at 10:01
  • This is a really nice approach. I have to check whether the remote server can enable WinRM. Thanks. – Kiril Nov 28 '14 at 10:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.