ProLiant Servers (ML,DL,SL)
1845882 Members
3995 Online
110250 Solutions
New Discussion

Re: Bug on iLo connect with POSH REST?

 
SOLVED
Go to solution
Marcel_D
Advisor

Bug on iLo connect with POSH REST?

Hi,

not shure, if this is a Bug...

I am collecting Powerinformation from a couple of iLos in a 5 Minute Loop. I am using an AD-Account for this. The Loop runs 3 times without any Problems. With the 4th run, the iLos start with Connection-Issues.

Invoke-WebRequest : The remote server returned an error: (401) Unauthorized. At C:\scripts\iLo-Scripte\draft_iLo_REST_Powerconsumtion.ps1:19 char:20 + ... $session = Invoke-WebRequest -Uri "https://$ilo/redfish/v1/Sessions" ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
 

After this, it is not possible to connect with an AD-Account anymore. I have to Reset the iLo to make the AD-Login work again. Seems to be no Problem with an Local Account.

Is there any experience on this?

 

 

$ilos @("iLo1","iLo2",...)
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$bodycred = @{
        "UserName"= $ilocred.UserName
        "Password"=$ilocred.GetNetworkCredential().Password
    } | ConvertTo-Json

do{

    Write-Host "Script starts/continuing collecting $(get-date) ..."
    foreach($ilo in $ilos){        
        
        Write-Host "Collecting from $ilo..." -foregroundcolor Cyan
        $session = Invoke-WebRequest -Uri "https://$ilo/redfish/v1/Sessions" -Method Post -Body $bodycred -ContentType "application/json" 
       -UseBasicParsing 
        $AuthHeaders = @{ "X-Auth-Token" = $Session.Headers.'X-Auth-Token' }

        #Datacollection every 10 seconds from the last 5 Minnutes
        $r = @()
        $r = Invoke-WebRequest -Uri "https://$ilo/redfish/v1/chassis/1/power/fastpowermeter" -Method get -Headers $AuthHeaders - 
        ContentType "application/json"
        $powerreading = (($r.Content | ConvertFrom-Json).powerdetail) | Select-Object -Last 30 | select 
        Time,Average,CpuWatts,DimmWatts,Minimum,Peak
        $powerreading | Export-Csv c:\Temp\$($ilo)Powerreading.csv -Append -Delimiter "," -NoTypeInformation 

    }

    Write-Host "Script sleeping 5 Minutes $(get-date)..."
    sleep 300

}until ($i -eq "2")

 

 

POSH-Version: 5.1

HPEiLOCmdlets: 4.2.0.0

ILO-Version: iLo 5 v3.01

 

6 REPLIES 6
support_s
System Recommended

Query: Bug on iLo connect with POSH REST?

System recommended content:

1. HPE iLO 6 1.57 User Guide | Directory authentication and authorization settings in iLO

2. HPE iLO 5 3.02 User Guide | Directory authentication and authorization settings in iLO

 

Please click on "Thumbs Up/Kudo" icon to give a "Kudo".

 

Thank you for being a HPE valuable community member.


Accept or Kudo

TVVJ
HPE Pro

Re: Bug on iLo connect with POSH REST?

Hello,

Please refer to the RESTful Interface Tool User Guide and see if it helps.

Regards,



I work at HPE
HPE Support Center offers support for your HPE services and products when and how you need it. Get started with HPE Support Center today.
[All opinions expressed here are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo
Suvamay
HPE Pro

Re: Bug on iLo connect with POSH REST?

Please try installing latest HPEiLOCmdlets and check 

https://support.hpe.com/connect/s/softwaredetails?softwareId=MTX_f775bbe394154fbda123632379&language=en_US&tab=revisionHistory

I'm an HPE employee.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo
Suvamay
HPE Pro

Re: Bug on iLo connect with POSH REST?

Please update

I'm an HPE employee.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo
Marcel_D
Advisor

Re: Bug on iLo connect with POSH REST?

I am using REST for Connecting to the iLo's. So using the newest iLo-Cmdlets isn't a helpful solution for this specific issue.

 

RoyAtkins
HPE Pro
Solution

Re: Bug on iLo connect with POSH REST?

Hi,

I'm not saying this is your problem, but as with all REStful interfaces, it is best practise to disconnect the session after you're done. Otherwise you run the risk of reaching the session limit on the iLO. Sessions expire after 30 mins by default, so its unlikely in your case.

However, why not try either of the following to see if your code becomes more robust?

  1. don't reconnect to a new session each time - an initial session created before the loop will stay active, as long as you make a request before the 30 minute expiry.
  2. disconnect the session each time following your query.
Roy
I'm an HPE employee.
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
Accept or Kudo