I get more than one remote source not supported error on pscp if my script is written like this (no issues with plink) :
I want to retrieve files from multiple UNIX servers to local windows Could someone help me to verify my code?
#Server Information:
$Server_IP=@("root@192.168.13.10","root@192.168.13.11")
$PPK_Path="C:\Users\me\Desktop\private-key.ppk"
#Local machine related information
$Dest_Path=@("C:\Users\me\Desktop\savehere01\","C:\Users\me\Desktop\savehere02\")
#Commands //Change with cautious
For ($i=0; $i -le 2; $i++) {
#Prompt computer to start plink.exe to insert private key and enable ssh
Echo "n" | plink -ssh -i $PPK_Path $Server_IP[$i]
#Prompt Powershell to run scp
pscp -r $Server_IP[$i]:/cf/conf/backup/* $Dest_Path[$i]
}
However, if i run my script as below, i am able to retrieve files from multiple servers to one single local host.
Echo "y" | plink -ssh -i C:\Users\me\Desktop\private-key.ppk root@192.168.13.32
pscp -pw testing -r root@192.168.13.10:/cf/conf/backup/* C:\Users\me\Desktop\savehere\
Echo "y" | plink -ssh -i C:\Users\me\Desktop\private-key.ppk root@192.168.13.11
pscp -pw testing -r root@192.168.13.11:/cf/conf/backup/* C:\Users\me\Desktop\savehere02\
EDIT
foreach ($IP in $Server_IP){
#Prompt computer to start plink.exe to insert private key and enable ssh
Echo "y" | plink -ssh -i $PPK_Path $IP
#Prompt Powershell to run pscp
pscp -pw testing -r $IP":"/cf/conf/backup/* C:\Users\me\Desktop\savehere\
}