Servers - General
1823063 Members
3244 Online
109645 Solutions
New Discussion юеВ

RedFish - HPERedFishCMdlets - Error when connecting

 
Johannes219
Occasional Advisor

RedFish - HPERedFishCMdlets - Error when connecting

Hi,

i try to use the HPERedFishCMdlets for PowerShell (v7.2) on a Windows 2012 R2 System, but i got the following error when i try to connect to an HPE Proliant DL380 Gen10 Server (ILO 5):

$cred = Import-Clixml -Path "[path to credentials.xml]"
Connect-HPERedfish -Address [ip-address] -Credential $cred -DisableCertificateAuthentication

Error: InvalidOperation: The property 'Expect100Continue' cannot be found on this object. Verify that the property exists and can be set.

Any help is appreciated.

Regards,
Johannes

6 REPLIES 6
Johannes219
Occasional Advisor

Re: RedFish - HPERedFishCMdlets - Error when connecting

Small Update - i have found out, that the connect-hpeRedFish Command works correctly on the windows integrated PowerShell 5.1:

ps5.png

Unfortunately i haven't found out the difference to PowerShell 7.2 until yet:

ps7-error.png

However, i have one difference. The System has Internet Connection over an authenticating proxy. Although i tried to removing any customized proxy settings, in contrast to PowerShell 5.1, PowerShell 7 starts every new session with an definied proxy. So i must set "[system.net.webrequest]::DefaultWebProxy = new-object system.net.webproxy($null)" to remove the proxy settings. I have checked out every settings, but i haven't found out, where PowerShell is getting the proxy settings, Neither PowerShell Profile, Internet Proxy Settings, nor  envirenonment variables like http_proxy or https_proxy are set. Policy Settings are excluded- this proxy is not distributed over the system policies.

I don't know if this could affect the Expect100Continue Problem.

 

Best regards

Johannes

Johannes219
Occasional Advisor

Re: RedFish - HPERedFishCMdlets - Error when connecting

Hi,

is there no one who can help here?

 

Best regards

Johannes

Parvez_Admin
Community Manager

Re: RedFish - HPERedFishCMdlets - Error when connecting

Hello @Johannes219 

As there is no response to the query yet, I would recommend to directly contact technical support and log a support call for quicker resolution. Please refer the links below for support ticket options:

https://support.hpe.com/help/en/Content/supportAndOtherResources.html

https://www.hpe.com/psnow/doc/A00039121ENW


Thanks,
Parvez_Admin
I work for HPE
[Any personal opinions expressed are mine, and not official statements on behalf of Hewlett Packard Enterprise]
CM_Cert_Logo_Color.png
Johannes219
Occasional Advisor

Re: RedFish - HPERedFishCMdlets - Error when connecting

Hello,

i simply have deactivated the Expect100Continue now:

$httpWebRequest.ServicePoint.Expect100Continue = $false

 

But when i try to connect i become to followed error:

Exception: Exception calling "GetResponse" with "0" argument(s): "The SSL connection could not be established, see inner exception."

 

With "$Errors[0].Exception.InnerException | FL *" i get the followed error:

InvalidOperation: Cannot index into a null array.

 

I have found some solutions on https://stackoverflow.com/questions/34331206/ignore-ssl-warning-with-powershell-downloadstring to set ServerCertificateValidationCallback to $true, but it did not help:

[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}

 

Also, to get the line of this error, i have copied the CMDLet Functions in own script and renamed the function "Connect-HPERedfish2"
The Result of this Error is on Line 1723:

[System.Net.WebResponse] $resp = $httpWebRequest.GetResponse()

 

All commands to create variable $httpsWebRequest before the Line 1723 are listed below:

$wr = [System.Net.WebRequest]::Create($Uri)
$httpWebRequest = [System.Net.HttpWebRequest]$wr
$httpWebRequest.Method = $Method
$httpWebRequest.AutomaticDecompression = [System.Net.DecompressionMethods]::GZip
$httpWebRequest.Headers.Add('Odata-version','4.0')
$httpWebRequest.ServicePoint.Expect100Continue = $false
$httpWebRequest.Headers.Add('X-Auth-Token',$Session.'X-Auth-Token'
$httpWebRequest.ServerCertificateValidationCallback = {$true}

 

The $session variable is definied as followed:

$session = New-Object PSObject
$session|Add-Member -MemberType NoteProperty 'RootUri' $rootUri
$session|Add-Member -MemberType NoteProperty 'X-Auth-Token' $webResponse.Headers['X-Auth-Token']
$session|Add-Member -MemberType NoteProperty 'Location' $webResponse.Headers['Location']
$session|Add-Member -MemberType NoteProperty 'RootData' $rootData
$session|Add-Member -MemberType NoteProperty 'DisableExpect100Continue' $DisableExpect100Continue

 

Additionally, i have tried to connect to the Server with the Invoke-Webrequest:

Invoke-WebRequest https://<IP-Address>/ -SkipCertificateCheck

This was successfull.

Referring to the inner Exception, the $httpWebRequest.GetResponse() is $null. But why?

 

 

Johannes219
Occasional Advisor

Re: RedFish - HPERedFishCMdlets - Error when connecting

Hello,

i have a couple of updates - while i create my own script depending on the HPE ConnectCMDLet, i have found out, that the system proxy settings works against me.

With the line:

[System.Net.WebResponse] $resp = $httpWebRequest.GetResponse()

i got the following error:

Line |
72 | [System.Net.WebResponse] $resp = $httpWebRequest.GetResponse()
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception calling "GetResponse" with "0" argument(s): "The proxy tunnel request to proxy 'http://<proxyUri>/' failed with status code '403'.""

Doesn't matter that the authentication fails - the connection should definitly not use this proxy.

So, i tried to reset the proxy with following line:

[System.Net.Webrequest]::DefaultWebProxy = New-object System.Net.Webproxy($null)

 

This results in the root failure again:

Line |
69 | $httpWebRequest.ServicePoint.Expect100Continue = -not($DisableExpect1 тАж
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The property 'Expect100Continue' cannot be found on this object. Verify that the property exists and can be set.

 

Then, i tried to configure the webproxy including bypass parameters in reference to https://stackoverflow.com/questions/28434480/creating-proxy-with-bypass-list-fails-if-it-contains

$proxyUri = "http<proxy:port>"
$snwr = [System.Net.Webrequest]::DefaultWebProxy = new-object System.Net.Webproxy($proxyUri, $true)
$snwr.Credentials = Import-Clixml -Path "<path-to-credentials>"
$snwr.BypassArrayList.Add("localhost")
$snwr.BypassArrayList.Add("*.local")
$snwr.BypassArrayList.Add("127.0.0.0/8")
$snwr.BypassArrayList.Add("172.16.0.0/16")
$snwr.BypassArrayList.Add("192.168.0.0/16")
$snwr.BypassProxyOnLocal = $true

 

But the bypasslist does not work. The only thing that works is "localhost':

$snwr.IsBypassed("https://localhost") >> returns true
$snwr.IsBypassed("https://192.168.1.1") >> returns false
$snwr.IsBypassed("https://website.local") >> returns false

 

Additionally, i used the ip-addresses without apostrophes, but without success. Even the "192.168.* does not work.
There is annother property, called "BypassArrayList.AddRange" There, i don't know which value is valid, i become the followed error every time:

Line |
47 | $snwr.BypassArrayList.AddRange(192.168.0.0/8)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Cannot convert argument "c", with value: "0", for "AddRange" to type "System.Collections.ICollection": "Cannot convert the "0" value of type "System.Int32" to type "System.Collections.ICollection"."

 

In Conclusion - its not a basically error in PowerShell 7, more an error with the proxy settings. I hope, when the proxy settings are correct / bypassed, the connection to the server will success.

How do I configure the proxy bypass settings to work properly?

Regards
Johannes

Johannes219
Occasional Advisor

Re: RedFish - HPERedFishCMdlets - Error when connecting

Hi,

The proxy settings are reset does not cause problems anymore.

The root cause for this problem are incompatibilities about the ServerCertificateValidationCallback property of ServicePointManager in PowerShell Core+.

The property is only supported in PowerShell 5.1, not in PowerShell Core and newer.

Links:

https://get-powershellblog.blogspot.com/2017/12/powershell-core-web-cmdlets-in-depth.html

ServerCertificateValidationCallback causes problems with secure connections ┬╖ Issue #13597 ┬╖ PowerShell/PowerShell

Capturing SSL errors

macos - Getting "Unable to find type [System.Net.ServicePointManager]." in PowerShell for OS X - Stack Overflow

HttpWebRequest/HttpClient with self-signed client certificate ┬╖ Issue #17154 ┬╖ dotnet/runtime

 

Is there a way to update the HPE RedFish CMDLets?

Regards

Johannes