日期:2014-05-17 浏览次数:20912 次
$Host.UI.RawUI.WindowTitle="同步脚本"
function ScriptBlock{param($hostname,$username,$password,$command)
Set-Location "C:\Users\Administrator\Desktop\PuTTY" #设置plink工作路径
$comandstr="cmd.exe /c plink.exe $username`@$hostname -pw $password $command"
$msg=invoke-expression $comandstr -ea SilentlyContinue
return $hostname,$msg
}
$a = new-object -comobject wscript.shell
$intAnswer = $a.popup('选择"是"全部同步,选择"否"只同步launcher,选择"取消"将终止同步', 0,"文件选择",3+32)
If ($intAnswer -eq 6) {
$select="all"
} elseif ($intAnswer -eq 7){
$select="launcher"}else{
exit
}
$c=Get-Credential root
$hostname="192.168.88.124"
$username=$c.GetNetworkCredential().username
$password=$c.GetNetworkCredential().password
$command="/root/appshell/xget-source.sh $select"
Write-Host "正在执行获取操作,请等待……"
ScriptBlock $hostname $username $password $command
$command="/root/appshell/xpush-file.sh $select"
Write-Host "正在执行推送操作,请等待……"
ScriptBlock $hostname $username $password $command
Read-Host "任务已经完成,按任意键结束。"
PLINK.EXE -ssh -v -pw MyPassword MyAccount@MyIP -m MyScript.sh > MyLog.txt