Skip to content

Instantly share code, notes, and snippets.

@tackme31
Created July 9, 2019 05:10
Show Gist options
  • Save tackme31/782f53b31212f88fe53bcf218fe20a7b to your computer and use it in GitHub Desktop.
Save tackme31/782f53b31212f88fe53bcf218fe20a7b to your computer and use it in GitHub Desktop.
A PowerShell script for comparing the HTMLs fetched by Invoke-WebRequest
function Get-HtmlContent($url)
{
Invoke-WebRequest $url `
| select -ExpandProperty Content `
| % {$_.Split([Environment]::NewLine, [StringSplitOptions]::RemoveEmptyEntries)}
}
$html1 = Get-HtmlContent "https://foo.example.com"
$html2 = Get-HtmlContent "https://bar.example.com"
if (-not (Compare-Object $html1 $html2))
{
Write-Host "no differences"
}
else
{
Write-Host "has differences"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment