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=@("[email protected]","[email protected]")
$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 [email protected]
pscp -pw testing -r [email protected]:/cf/conf/backup/* C:\Users\me\Desktop\savehere\
Echo "y" | plink -ssh -i C:\Users\me\Desktop\private-key.ppk [email protected]
pscp -pw testing -r [email protected]:/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\
}
echo "n"? Add-vto plink command line and show us the output that you get.