Oh. No. It’s ‘get’ vs. ‘put’ for the Method.

From: listsad...@lists.myitforum.com [mailto:listsad...@lists.myitforum.com] On 
Behalf Of Kurt Buff
Sent: Tuesday, May 9, 2017 6:59 PM
To: powershell@lists.myitforum.com
Subject: Re: [powershell]

Well OK, then. That's pretty slick.
Thanks!
The key seems to be using:
[System.Net.ServicePointManager]::SecurityProtocol = 'Tls12'
vs.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

Correct?

Kurt

On Tue, May 9, 2017 at 3:12 PM, Michael B. Smith 
<mich...@smithcons.com<mailto:mich...@smithcons.com>> wrote:
Close, but no cigar. ☺

The below works fine.

$email = 'kurt.b...@gmail.com<mailto:kurt.b...@gmail.com>'
$url   = 'https://haveibeenpwned.com/api/v2/pasteaccount/' + $email

[System.Net.ServicePointManager]::SecurityProtocol = 'Tls12'
Invoke-Restmethod -Uri $url -Method Put

The default SecurityProtocol depends on a number of things. Don’t worry too 
much about that.

From: listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com> 
[mailto:listsad...@lists.myitforum.com<mailto:listsad...@lists.myitforum.com>] 
On Behalf Of Kurt Buff
Sent: Sunday, May 7, 2017 10:35 PM
To: powershell@lists.myitforum.com<mailto:powershell@lists.myitforum.com>
Subject: [powershell]

So, I want to know what's been breached. I use a different password for each 
site, but I can't seem to figure this out - I'm pretty sure it's going to be 
obvious that I don't know what I'm doing here. Any pointers would be 
appreciated..

This:
https://www.troyhunt.com/password-reuse-credential-stuffing-and-another-1-billion-records-in-have-i-been-pwned/
Leads to this:
https://haveibeenpwned.com/API/v2
And a couple of bits of googling leads me to this:
http://stackoverflow.com/questions/41618766/powershell-invoke-webrequest-fails-with-ssl-tls-secure-channel

With this result:
     PS C:\temp>[Net.ServicePointManager]::SecurityProtocol = 
[Net.SecurityProtocolType]::Tls12
     PS C:\temp>invoke-restmethod -uri 
https://haveibeenpwned.com/api/v2/pasteaccount/kurt.b...@gmail.com -method get
     invoke-restmethod : The remote server returned an error: (404) Not Found.
     At line:1 char:1
      + invoke-restmethod -uri https://haveibeenpwned.com/api/v2/pasteaccount 
...
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         + CategoryInfo          : InvalidOperation: 
(System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
         + FullyQualifiedErrorId : 
WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
Since this page shows a lot of successful queries:
https://haveibeenpwned.com/API/Consumers
I figure the page owner hasn't screwed things up, and this is all about my lack 
of knowledge...

Kurt





Reply via email to