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..?