I had the same error (PS 5.1 on Windows 10 1703), but this did work for me:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$email = "u...@email.com"
Invoke-WebRequest "https://haveibeenpwned.com/API/v2/breachedaccount/$email";


DAMIEN SOLODOW
IT Engineering Lead
317.447.6033 (office)
HARRISON COLLEGE

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

Unknown why it's not working for me. This is my attempt in an elevated session, 
and as you can see I'm running v5 also.

[Inline image 1]
I'm definitely stumped, and don't know what to look at next.
I'm not behind a firewall, either - I've got a public IP address on this 
machine.

Kurt

On Tue, May 9, 2017 at 10:48 AM, BURKEY Evan 
<evan.bur...@odot.state.or.us<mailto:evan.bur...@odot.state.or.us>> wrote:
$email = "myem...@provider.com<mailto:myem...@provider.com>"
$data = Invoke-WebRequest 
"https://haveibeenpwned.com/api/v2/breachedaccount/$email";
echo $data

This works fine for me in PowerShell v5. Any reason why you’re being forced to 
use TLS?


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 7: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