CiscoDevNet / intersight-powershell

Cisco Intersight PowerShell
Apache License 2.0
16 stars 4 forks source link

Get-IntersightCondHclStatus - keeps returning "UnauthorizedOperation" #158

Closed aamodei closed 1 month ago

aamodei commented 3 months ago

Describe the bug When trying Get-IntersightCondHclStatus with no arguments, I get "Get-IntersightCondHclStatus: Error calling GetCondHclStatusList: {"code":"UnauthorizedOperation","message":"Cannot perform this operation without a 'Essential' license.","messageId":"barcelona_license_permission_denied","messageParams":{"1":"Essential"},"traceId":""}"

Our Intersight SaaS environment has 4 UCSM domains simply device connected/claimed for viewing and easy open of TAC use, all of those blades/Domains are NOT licensed. Under the same SaaS instance, I have 2 IMM Domains with blades that are all licensed with Essentials (and I confirmed the licenses are correct)

I tried to focus the cmdlet at just the MOID of a blade I know is licensed with Essentials, but that just gives the same message

To Reproduce Simply Run Get-IntersightCondHclStatus

Version used

Expected behavior Assuming this is the correct cmdlet to use (help is a little short on explanations (and I'm new to Intersight, but not UCS as a whole), I thought this would return pieces of the HCL status window, as I'm trying to create a report of HCL specifics for an internal report

Thanks in advance

briamorr commented 3 months ago

If you have any unlicensed servers in the account that would be expected from the backend. The same error will come back when doing an unfiltered GET via REST API on /api/v1/cond/HclStatuses if any of the servers are unlicensed

You'll have to first filter out servers by license type and then with ones having Essentials or higher licensing use the Get-IntersightCondHclStatus cmdlet specifically on those.

For example:

$servers = Get-IntersightComputePhysicalSummary -Top 1000 | Select Results -ExpandProperty Results | Select Serial, Moid -Expand Tags

foreach ($server in $servers)
{
  if ($server.Key -eq "Intersight.LicenseTier" -and $server.Value -eq "Base")
  {
    Write-Host "Server has base license, HCL is not applicable: " $server.Serial
  }
  elseif (($server.Key -eq "Intersight.LicenseTier" -and $server.Value -eq "Essential") -or ($server.Key -eq "Intersight.LicenseTier" -and $server.Value -eq "Advantage") -or ($server.Key -eq "Intersight.LicenseTier" -and $server.Value -eq "Premier"))
  {
    $hcl = Get-IntersightCondHclStatus -Filter ("ManagedObject.Moid eq '" + $server.Moid + "'") | Select Results -ExpandProperty Results
    Write-Host $server.Serial $server.Value $hcl.InvModel $hcl.InvOsVendor $hcl.InvOsVersion $hcl.Status
  }
  elseif ($server.Key -eq "Intersight.LicenseTier")
  {
    Write-Host "***Server has unknown license tag****: " $server.Serial $server.Value
  }
}

Output

XYZ1234 Advantage HX220C-M5SX VMware ESXi 6.7.0 3 Validated
ABC1234 Advantage ProLiant DL360 Gen10 Plus    Incomplete

If it is still returning that message on a specific server that is licensed correctly it would be recommended to have TAC take a look at your specific Intersight accounts config/backend as the error is coming from the backend.

aamodei commented 3 months ago

Excellent - thank you so much for the explanation and example! I had to dig in a little more, I knew there would be filtering at play, but I just couldn't find an example how to do so. I was able to get through this with your help and build the script/report for returning all HCL details across all servers that I wanted to. Thanks again