Skip to content

Instantly share code, notes, and snippets.

@shiguruikai
Created May 7, 2020 06:26
Show Gist options
  • Save shiguruikai/1a2642d4f2d1011723fbef5f4dab438c to your computer and use it in GitHub Desktop.
Save shiguruikai/1a2642d4f2d1011723fbef5f4dab438c to your computer and use it in GitHub Desktop.
function diffc(
[Parameter(Mandatory)]
[string]
$FileA,
[Parameter(Mandatory)]
[string]
$FileB
) {
Write-Host "--- $(Convert-Path $FileA)"
Write-Host "+++ $(Convert-Path $FileB)"
Write-Host
Compare-Object (Get-Content $FileA) (Get-Content $FileB) |
ForEach-Object {
$line = ""
$foreColor = ""
if ($_.SideIndicator -eq "=>") {
$line = "+ " + $_.InputObject
$foreColor = "Green"
}
elseif ($_.SideIndicator -eq "<=") {
$line = "- " + $_.InputObject
$foreColor = "Red"
}
Write-Host $line -ForegroundColor $foreColor
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment