0

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\

}
2
  • What do you mean by "insert private key"? Why are you doing echo "n"? Add -v to plink command line and show us the output that you get. Commented Mar 2, 2020 at 6:40
  • @MartinPrikryl nevermind that, i could plink successfully into each server... however for now, the pscp is getting** more than one remote source is not supported**. However, I already specified the path to where i want to retireve the files .... Commented Mar 2, 2020 at 6:58

1 Answer 1

0

I found some erros in your code: 1)Put this line

$Server_Username[$i]+"@"+$Server_IP[$i]   

instead

${Server_Username[$i]}@${Server_IP[$i]}

2)You have only 2 elements in array your loop must be

($i=0; $i -lt 2; $i++) 

3)You can use just this construction

$Dest_Path[$i]

instead

${Dest_Path[$i]}

Additional:

#Commands //Change with cautious

For ($i=0; $i -lt 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]

}

Try this fix

Sign up to request clarification or add additional context in comments.

15 Comments

hi yes i just realised that tq for pointing out. However now im getting More than one remote source is not supported on pscp even though i specified the absolute path.... And it keep llisting the whole option list of pscp as if to prompt me to enter an option for it
Try this pscp -r $Server_IP[$i]:/cf/conf/backup/* $Dest_Path[$i] if it can't more than one remote source, try add some pause in end. pscp – is utility for copying files in parallel to a number of hosts. prsync – is a utility for efficiently copying files to multiple hosts in parallel. pnuke – it helps to kills processes on multiple remote hosts in parallel. pslurp – it helps to copy files from multiple remote hosts to a central host in parallel. look what you want.
It seems pscp would not copy from multiple remote host....it seems that pslurp suits my current situation the most... however im getting pslurp is not recognised. Do i need to install extra package for pslurp?
It's inside package Parallel SSH Tools
It's inside package Parallel SSH Tools. If all your machines use windows you can do Copy-item cmdlet, it supports remote copy.look this thread
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.