Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create br-surebackup-sshexecute.ps1 #205

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions BR-Surebackup-Remote-executeCommand/br-surebackup-sshexecute.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<#
accepts certifs automatically
#>
param(
$fexist = "/veeam/oracle_start.sh",
$plink = "C:\Program Files\Veeam\Backup and Replication\Backup\Putty\plink.exe",
#test lab vm information
$ip = "your vm ip",
$username = "root",
$password = "your password"
)

write-host "Running $fexist @ $ip"
$argplink = @("-v", $ip, "-l", $username, "-pw", $password, "bash /veeam/oracle_start.sh")

$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$pinfo.FileName = $plink
$pinfo.RedirectStandardError = $true
$pinfo.RedirectStandardOutput = $true
$pinfo.RedirectStandardInput = $true
$pinfo.UseShellExecute = $false
$pinfo.Arguments = $argplink

$p = New-Object System.Diagnostics.Process
$p.StartInfo = $pinfo
$p.Start() | Out-Null
$p.StandardInput.Write("yes")
$p.WaitForExit()

$stdout = $p.StandardOutput.ReadToEnd()
$stderr = $p.StandardError.ReadToEnd()

if($stdout) {
write-host ("Output: {0}" -f $stdout.trim())
exit 0
} else {
write-host "No output returned or something went wrong... dumping $stderr"
$stderr >> c:\bin\log.txt
exit 1
}