Skip to content

Instantly share code, notes, and snippets.

@Daenks
Last active March 31, 2016 01:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Daenks/14fefd7df81a07309e07 to your computer and use it in GitHub Desktop.
Save Daenks/14fefd7df81a07309e07 to your computer and use it in GitHub Desktop.
Check haveibeenpwned.com's breach repository for an exchange 2007+ environment (requires PoweShell 3+ and Exchange Module Loaded)
Get-Mailbox -ResultSize Unlimited | ForEach-Object { }
$Mailboxes = Get-Mailbox -ResultSize Unlimited
$Results = @()
foreach ($mailbox in $Mailboxes)
{
$s = $mailbox.PrimarySmtpAddress.ToString() -replace "@","%40"
$r = $null
$r = Invoke-WebRequest -URI "https://haveibeenpwned.com/api/v2/breachedaccount/$($s)" -Method GET -UserAgent "PsBreachFinder" -ErrorAction SilentlyContinue
if ($r -ne $null)
{
$result = New-Object -TypeName PSObject
$result | Add-Member NoteProperty EmailAddress($($mailbox.PrimarySmtpAddress.ToString()))
$result | Add-Member NoteProperty Result($r)
$Results += $result
}
}
$Results | Format-Table -AutoSize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment