Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

If Compar-object gets results then...

$
0
0

Hi colleagues. I am comparing 2 text files, one on a server and the other on different hosts.

To accomplish this I use compar-object, and as output I get the hostname and below the differences between files (RESULTS.TXT).

$SEP="--------------------------------------" | out-file $RESULTS -append
get-content env:computername | out-file $RESULTS -append
compare-object (get-content $SERVER) (get-content $HOST) | where { $_.SideIndicator -eq '<='} | % { $_.InputObject } | out-file $RESULTS -append
$SEP="--------------  END  -----------------" | out-file $RESULTS -append

I would like to get output on 2 files, not 1. On one file computers that have differences between files, and on the other file computer with no differences.

How can I do this? Is if possible to use an IF statement?

Thanks.



Viewing all articles
Browse latest Browse all 21975

Trending Articles