Hp OneView Uživatelský manuál Strana 291

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 305
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 290
$hostname = $hostname.Trim().ToLower()
if (!$hostname.StartsWith("https://"))
{
if ($hostname.StartsWith("http://"))
{
$hostname = $hostname.Replace("http","https")
} else {
$hostname = "https://" + $hostname
}
}
Write-Host "Enter user name"
$secUsername = Read-Host -AsSecureString
$username =
[Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($secUsername))
Write-Host "Enter password"
$secPassword = Read-Host -AsSecureString
$password =
[Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($secPassword))
$absolutePath = $backupDirectory + $backupFile
$loginVals = @{ hostname = $hostname; userName = $username; password = $password; backupPath = $absolutePath;
backupFile = $backupFile; }
return $loginVals
}
##### getApiVersion: Get X_API_Version #####
function getApiVersion ([int32] $currentApiVersion,[string]$hostname)
{
<#
.DESCRIPTION
Sends a web request to the appliance to obtain the current Api version.
Returns the lower of: Api version supported by the script and Api version
supported by the appliance.
.PARAMETER currentApiVersion
Api version that the script is currently using
.PARAMETER hostname
The appliance address to send the request to (in https://{ipaddress} format)
.INPUTS
None, does not accept piping
.OUTPUTS
Outputs the new active Api version
.EXAMPLE
$global:scriptApiVersion = getApiVersion()
#>
# the particular Uri on the Appliance to request the Api Version
$versionUri = "/rest/version"
# append the Uri to the end of the IP address to obtain a full Uri
$fullVersionUri = $hostname + $versionUri
# use setup-request to issue the REST request api version and get the response
try
{
$applianceVersionJson = setup-request -Uri $fullVersionUri -method "GET" -accept "application/json"
-contentType "application/json"
if ($applianceVersionJson -ne $null)
{
$applianceVersion = $applianceVersionJson | convertFrom-Json
$currentApplianceVersion = $applianceVersion.currentVersion
if ($currentApplianceVersion -lt $currentApiVersion)
{
return $currentApplianceVersion
}
return $currentApiVersion
}
}
catch [System.Exception]
{
if ($global:interactiveMode -eq 1)
{
Write-Host $error[0].Exception.Message
C.2 Exemple de script de restauration 291
Zobrazit stránku 290
1 2 ... 286 287 288 289 290 291 292 293 294 295 296 ... 304 305

Komentáře k této Příručce

Žádné komentáře