HP Matrix 7.2 KVM Private Cloud Backup and Restore

Table Of Contents
{
$continue = 1
}
} while ($continue -eq 0)
do
{
Write-Host "Enter directory backup is located in (ie: C:\users\joe\)"
$backupDirectory = Read-Host
# Add trailing slash if needed
if (!$backupDirectory.EndsWith("\"))
{
$backupDirectory = $backupDirectory + "\"
}
Write-Host "Enter name of backup (ie: appliance_vm1_backup_2012-07-07_555555.bkp)"
$backupFile = Read-Host
# Check if file exists
$fullFilePath = $backupDirectory + $backupFile
if (! (Test-Path $fullFilePath))
{
Write-Host "Sorry the backup file $fullFilePath doesn't exist."
}
} while (! (Test-Path $fullFilePath))
Write-Host "Enter appliance IP address (ie: https://10.10.10.10)"
$hostname = Read-Host
# Correct some common errors
$hostname = $hostname.Trim().ToLower()
if (!$hostname.StartsWith("https://"))
{
if ($hostname.StartsWith("http://"))
{
$hostname = $hostname.Replace("http","https")
} else {
$hostname = "https://" + $hostname
}
}
Write-Host "Enter username"
$secUsername = Read-Host -AsSecureString
$username =
[Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStr
ingToBSTR($secUsername))
Write-Host "Enter password"
$secPassword = Read-Host -AsSecureString
$password =
[Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStr
ingToBSTR($secPassword))
$absolutePath = $backupDirectory + $backupFile
$loginVals = @{ hostname = $hostname; userName = $username; password = $password; backupPath
= $absolutePath; backupFile = $backupFile; }
return $loginVals
}
##### Send the login request to the appliance #####
function login-appliance ([string]$username,[string]$password,[string]$hostname)
{
<#
.DESCRIPTION
Attempts to send a web request to the appliance and obtain a authorized sessionID.
.PARAMETER username
The username to log into the remote appliance
.PARAMETER password
The correct password associated with username
.PARAMETER hostname
The appliance address to send the request to (in https://{ipaddress} format)
.INPUTS
None, does not accept piping