Closed dmoroney closed 5 months ago
You cannot use a OneView PowerShell library version that is higher than the version number of the OneView appliance you want to connect to. Since you say it works with library versions 8.30 and 8.40, you're likely trying to connect to a OneView appliance version 8.40, so you cannot use a OneView library version > 8.40
Confirmed. Revised the code to catch the API mis-match condition.
#!/usr/bin/env pwsh
#Requires -Version 7.3
#Requires -Modules @{ ModuleName="TUN.CredentialManager"; ModuleVersion="3.0" }
# remove the 'Nulled' string below to make this Requires take effect
#NulledRequires -Modules @{ ModuleName="HPEOneView.840"; ModuleVersion="8.40" }
$cred = Get-StoredCredential -Target SynergyOneView
try {
$null = $cred.GetNetworkCredential()
}
catch {
Write-Error "WCM ERROR: invalid or missing WCM credentials"
exit
}
$parameters = @{
Hostname = 'RedactedFqdn'
Credential = $cred
LoginAcknowledge = $true
}
[HPEOneView.Config]::EnableVerbose = $false
[HPEOneView.Config]::EnableDebug = $false
Write-Host "Current installed OneView Library"
$LibraryVersion = Get-OVVersion
Write-Host "LibraryVersion: $($LibraryVersion.LibraryVersion)`n"
$ExtraInformation = "if this is a X-API-Version error, then it is likely the Library and Appliance Versions are mis-matched. The #Requires statement here can be used to avoid this problem."
Write-Host "connecting to $($parameters.Hostname)..." -NoNewline
try {
$Connection = Connect-OVMgmt @parameters 6> $null
}
catch {
Write-Host "`n"$_.Exception.Message -f red
Write-Host "$ExtraInformation`n" -f Yellow
exit
}
Write-Host "success"
# information that requires a prior working connection...
Write-Host "getting the OneView Appliance version..." -NoNewline
$ApplianceVersion = Get-OVVersion -ApplianceVer
Write-Host "success.`n$($ApplianceVersion.$($parameters.Hostname)) X-API-Version: $($ApplianceVersion.$($parameters.Hostname).XApiVersion)"
Write-Host "disconnecting..." -NoNewline
Disconnect-OVMgmt -Hostname $Connection
Write-Host "success`n"
exit
Expected Behavior
the code in Steps to Reproduce successfully connects using HPEOneView.830 and HPEOneView.840
Actual Behavior
Steps to Reproduce
Generated Output
Version Information