HP OneView Benutzerhandbuch
Seite 301

restore-status *$authinfo* -hostname $hostname -restoreResponse $restoreResponse
or
restore-status -hostname $hostname -recoveredUri $recoveredUri
#>
# append the appropriate URI to the IP address of the Appliance
if ($recoveredUri -ne "")
{
$fullStatusUri = $hostname + $recoveredUri
write-host $fullStatusUri
}
else
{
$fullStatusUri = $hostname + $restoreResponse.uri
}
do
{
try
{
# create a new webrequest and add the proper headers (new header, auth is needed for authorization
$rawStatusResp = setup-request -uri $fullStatusUri -method "GET" -accept "application/json" -contentType
"application/json" -authValue $authinfo
$statusResponse = $rawStatusResp | convertFrom-Json
$trimmedPercent = ($statusResponse.percentComplete) / 5
$progressBar = "[" + "=" * $trimmedPercent + " " * (20 - $trimmedPercent) + "]"
Write-Host "`rRestore progress: $progressBar " $statusResponse.percentComplete "%" -NoNewline
}
catch [Net.WebException]
{
try
{
$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 "`r`n" $error[1].Exception
}
return
}
if ($statusResponse.status -eq "SUCCEEDED")
{
Write-Host "`r`nRestore complete!"
return
}
if ($statusResponse.status -eq "FAILED")
{
Write-Host "`r`nRestore failed! System should now undergo a reset to factory defaults."
}
Start-Sleep 10
} while ($statusResponse.status -eq "IN_PROGRESS")
return
}
##### Recovers Uri to the restore resource if connection lost #####
function recover-restoreID ([string]$hostname)
{
<#
.DESCRIPTION
Uses GET requests to check the status of the restore process.
.PARAMETER hostname
The appliance to end the request to.
.INPUTS
None, does not accept piping
.OUTPUTS
The Uri of the restore task in string form.
.EXAMPLE
$reacquiredUri = recover-restoredID $hostname
#>
$idUri = "/rest/restores/"
$fullIdUri = $hostname + $idUri
try
{
$rawIdResp = setup-request -uri $fullIdUri -method "GET" -contentType "application/json" -accept
C.2 Beispiel für ein Wiederherstellungsskript 301