.net - unable to bypass CertificateValidation inside my PS1 file -


i want write ps1 file called on timely basis using windows task scheduler (mainly 2 times per day), purpose of ps1 file call our internal web site keep application pool active, running background jobs within application pool scope .

so wrote following file:

$request = [system.net.webrequest]::create("https://localhost/") $response = $request.getresponse() $response.close() 

but raising following error:

exception calling "getresponse" "0" argument(s): "the underlying connection closed: not establish trust relationship ssl/tls secure channel."

so modify ps1 file, bypass security certificate follows:

$request = [system.net.webrequest]::create("https://localhost/") $response = $request.getresponse() $response.close() servicepointmanager.servercertificatevalidationcallback += (sender, certificate, chain, sslpolicyerrors) => certificate.issuer == "cn=localhost"; 

but raising following error:

at ******\apppoolactivation.ps1:4 char:67 + servicepointmanager.servercertificatevalidationcallback += (sender, certificate, ... +                                                                   ~ missing argument in parameter list.     + categoryinfo          : parsererror: (:) [], parentcontainserrorrecordexception     + fullyqualifiederrorid : missingargument

so can advice how can call local host keep application pool active prior executing background jobs, , bypass security certificate?


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -