Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows utility to copy file from a remote machine [closed]

I am looking for native windows utility or powershell cmdlet for doing this. (Not SSH server over Windows)

I have two machines on the same network. I want to copy files from machine1 to machine2 by executing some command on machine 2. That means I need to specify credentials for machine1 while copying the file.

I found the PsExec tool, which only allows copy file from psexec command execution machine to remote machine and execute it automatically. But, I don't want such behavior.

What is the best way to get the file from Machine1 onto machine2?

like image 759
Invincible Avatar asked Mar 02 '11 01:03

Invincible


3 Answers

Make a batch file that first authenticates against the remote box, and then copies the file.

run on machine1

@echo off
net use \\\\machine2\admin$ /user:machine2\Admind2 /password:password
copy \\\\machine2\c$\data.file c:\
net use \\\\machine2\admin$ /delete

Instead of using "copy" I would also look into using the free robocopy.exe utility instead.

like image 120
Anonymous Avatar answered Oct 08 '22 01:10

Anonymous


PowerShell Copy-Item does not support credentials for filesystem provider yet. So, that is ruled out.

Edit 2018 : Powershell since V5 supports remote connections. See the examples in the current documentation for Copy-Item

Copy a file to a remote computer

$Session = New-PSSession -ComputerName "Server01" -Credential "Contoso\PattiFul"
Copy-Item "D:\Folder001\test.log" -Destination "C:\Folder001_Copy\" -ToSession $Session

In 2011, PSExec was probably the only option you had. Also, check RemoteExec. http://www.isdecisions.com/en/software/remoteexec/

I have not tried it myself but it helps in copying files to/from a remote machine.

like image 36
ravikanth Avatar answered Oct 08 '22 02:10

ravikanth


Have you looked into the putty ssh client for doing scp and a windows-based ssh server? I cannot recommend a particular ssh server for the windows platform, though I'm sure there are plenty of openssh-based applications out there, but I highly recommend the process. It is one that you'll need to be familiar with in the long-term of a digital career, anyway.

like image 45
Sniggerfardimungus Avatar answered Oct 08 '22 00:10

Sniggerfardimungus