如果我的脚本是这样写的,我在pscp上得到多个不支持的远程源错误(plink没问题:)>]
我想将文件从多个UNIX服务器检索到本地窗口有人可以帮助我验证我的代码吗?
#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] }
但是,如果我按以下方式运行脚本,则可以将文件从多台服务器检索到一个本地主机。
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\
编辑
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\
}
如果我的脚本是这样写的,我会在pscp上获得多个不支持的远程源错误(plink没有问题):我想从多个UNIX服务器检索文件到本地Windows,可以...
我在您的代码中发现了一些错误:1)放入此行