HP OneView Manual del usuario

Página 300

Advertising
background image

{
$errorResponse = $error[0].Exception.InnerException.Response.getResponseStream()
$sr = New-Object IO.StreamReader ($errorResponse)
$rawErrorStream = $sr.readtoend()
$error[0].Exception.InnerException.Response.close()
$errorObject = $rawErrorStream | convertFrom-Json
Write-Host $errorObject.message $errorObject.recommendedActions
}
catch [System.Exception]
{
Write-Host $error[1].Exception.Message
}
throw
return

}
}

##### Begin main #####

#this checks to see if the user wants to just check a status of an existing restore
if ($args.count -eq 2)
{
foreach ($item in $args)
{
if ($item -eq "-status")
{
[void]$foreach.movenext()
$hostname = $foreach.current
# Correct some common errors in hostname
$hostname = $hostname.Trim().ToLower()
if (!$hostname.StartsWith("https://"))
{
if ($hostname.StartsWith("http://"))
{
$hostname = $hostname.Replace("http","https")
} else {
$hostname = "https://" + $hostname
}
}
}
else
{
Write-Host "Invalid arguments."
return
}
}

$reacquiredUri = recover-restoreID -hostname $hostname
if ($reacquiredUri -eq $null)
{
Write-Host "Error occurred when fetching active restore ID. No restore found."
return
}
restore-status -recoveredUri $reacquiredUri -hostname $hostname

return
}
elseif ($args.count -eq 0)
{
$loginVals = query-user
if ($loginVals -eq $null)
{
Write-Host "Error passing user login vals from function query-host, closing program."
return
}

#determines the active Api version
$global:scriptApiVersion = getApiVersion $global:scriptApiVersion $loginVals.hostname
if ($global:scriptApiVersion -eq $null)
{
Write-Host "Could not determine appliance Api version"
return
}

$authinfo = login-appliance $loginVals.userName $loginvals.password $loginVals.hostname
if ($authinfo -eq $null)
{
Write-Host "Error getting authorized session from appliance, closing program."
return

300 Ejemplos de secuencias de comandos de copia de seguridad y restauración

Advertising