0

I have 2 windows-servers. I need to run a PowerShell script on server A which will transfer a file (on server A) to server B. What is the best (most secure) way to do this? I found out 2 solutions on the internet and it's not very clear for me what's the difference between them.

Option 1: Copy-Item

Copy-Item -Path \\serverb\c$\programs\temp\test.txt -Destination \\servera\c$\programs\temp\test.txt;

Option 2: PSCP (.exe)

if(!$pass)    {$pass = Read-Host 'Enter Password'}
$pscp         = "`'C:\Program Files (x86)\PuTTY\pscp.exe`'"

"cmd /c ${pscp} -r -pw ${pass} ...

Option 3: Another (better) option..?

1

The other option is to create a share specifically for exchange between your two servers and by the way, you will can managing authorization on share.

Your second option is fine if your remote host has a SSH server because SCP protocol uses SSH for data transfer.

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.