Skip to content

Instantly share code, notes, and snippets.

@mitchelldavis
Created November 14, 2013 17:01
Show Gist options
  • Save mitchelldavis/7470367 to your computer and use it in GitHub Desktop.
Save mitchelldavis/7470367 to your computer and use it in GitHub Desktop.
A simple diff function for two files in powershell.
param($VersionOne, $VersionTwo)
$result = compare-object (get-content $VersionOne) (get-content $VersionTwo) -IncludeEqual
Write-Host "+ " $VersionOne -ForegroundColor DarkGray
Write-Host "- " $VersionTwo -ForegroundColor DarkGray
Write-Host "=======================================" -ForegroundColor DarkGray
$result | foreach {
if($_.SideIndicator -eq "==")
{
Write-Host " " $_.InputObject -ForegroundColor DarkGray
}
elseif($_.SideIndicator -eq "<=")
{
Write-Host "- " $_.InputObject -ForegroundColor Red
}
elseif($_.SideIndicator -eq "=>")
{
Write-Host "+ " $_.InputObject -ForegroundColor Green
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment