Hi,
I have problems writing a powershell script that will validate a https website. To make the script use the object WinHttp.WinHttpRequest.5.1. I need to define the WinHttpRequestOption_SslErrorIgnoreFlags to have control over the verification of certificates
More information about WinHttpRequestOption:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa384108(v=vs.85).aspx
This is the script:
$Url = "https://www.sample.com/Default.aspx"
$User = "user"
$Password = "password"
$Http = new-object -com "WinHttp.WinHttpRequest.5.1"
$Http.Option(4)=13056
$Http.open("GET", $Url, $false)
$Http.SetCredentials($User, $Password, $HttpREQUEST_SETCREDENTIALS_FOR_SERVER)
$Http.send()
$Body = $Http.responseText
$Body
This is the error:
Exception setting "Option": "Value does not fall within the expected range."
At C:\Users\alberto.puente.gomez\AppData\Local\Temp\60240db8-5140-4929-8a41-6cd7836a2b39.ps1:10 char:13
+ $Http.Option <<<< (4)=13056
+ CategoryInfo : NotSpecified: (:) [], SetValueInvocationException
+ FullyQualifiedErrorId : CatchFromBaseAdapterParameterizedPropertySetValueTI
More Info:
$Http | gm
TypeName: System.__ComObject#{016fe2ec-b2c8-45f8-b23b-39e53a75396b}
Name MemberType Definition
---- ---------- ----------
Abort Method void Abort ()
GetAllResponseHeaders Method string GetAllResponseHeaders ()
GetResponseHeader Method string GetResponseHeader (string)
Open Method void Open (string, string, Variant)
Send Method void Send (Variant)
SetAutoLogonPolicy Method void SetAutoLogonPolicy (WinHttpRequestAutoLogonPolicy)
SetClientCertificate Method void SetClientCertificate (string)
SetCredentials Method void SetCredentials (string, string, HTTPREQUEST_SETCREDENTIALS_FLAGS)
SetProxy Method void SetProxy (HTTPREQUEST_PROXY_SETTING, Variant, Variant)
SetRequestHeader Method void SetRequestHeader (string, string)
SetTimeouts Method void SetTimeouts (int, int, int, int)
WaitForResponse Method bool WaitForResponse (Variant)
Option ParameterizedProperty Variant Option (WinHttpRequestOption) {get} {set}
ResponseBody Property Variant ResponseBody () {get}
ResponseStream Property Variant ResponseStream () {get}
ResponseText Property string ResponseText () {get}
Status Property int Status () {get}
StatusText Property string StatusText () {get}
Do not know how to set a value in the ParameterizedProperty :(