Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

powershell forcing ssl version 3 for get requests

Tags:

powershell

I am wondering if one of the powershell, C# gurus can please shed some light on the how to force Sslv3 during a webrequest on Windows using [System.Net.WebRequest]

I would like to convert the following C# code to Powershell's equivalent:

 ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;

I tried adding the following code to my script but get and error that the term "Net.SecurityProtocolType.ssl3" is not recognized as the name of a cmdlet, scriptfile, function. Below is what I used in my code:

 [System.Net.ServicePointManager]::SecurityProtocol = Net.SecurityProtocolType.ssl3

Thanks for all the help!

like image 819
user1048209 Avatar asked Jun 12 '12 16:06

user1048209


1 Answers

Enumerations require the extended type square bracket syntax:

 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::ssl3

You could also just let PowerShell cast it for you:

[Net.ServicePointManager]::SecurityProtocol = 'ssl3'
like image 63
Aaron Jensen Avatar answered Nov 13 '22 05:11

Aaron Jensen