2

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?

4
  • How do you plan to store the credentials needed to make a connection? What privileges do those credentials have on the remote machine? Commented Nov 28, 2014 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
    Commented Nov 28, 2014 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
    Commented Nov 28, 2014 at 11:01
  • The connection is established by VPN, and only port 3389 is allowed to be open in the firewall...
    – Kiril
    Commented Dec 2, 2014 at 12:28

1 Answer 1

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.

3
  • 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
    Commented Nov 28, 2014 at 9:16
  • @Kiril, the post has been updated :)
    – Dave
    Commented Nov 28, 2014 at 10:01
  • This is a really nice approach. I have to check whether the remote server can enable WinRM. Thanks.
    – Kiril
    Commented Nov 28, 2014 at 10:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .