I am attempting to put the output of compare-object. I am new to Powershell and unfortunately don't know the ins and outs yet.
My command is as follows:
Compare-Object -referenceObject $(Get-Content "c:\temp\mek\123-first.txt") -differenceObject $(Get-Content "c:\temp\mek\123-second.txt") | %{$_.Inputobject} | sort-object | out-file "c:\temp\mek\results.txt"
The contents of my files are as follows (simply comparing Windows services):
systemname name state startmode ---------- ---- ----- --------- D7MCYP AdobeARMservice Stopped Auto D7MCYP AdobeFlashPlayerUpdateSvc Stopped Manual D7MCYP AeLookupSvc Stopped Manual
My results of the compare-object are as follows:
BL3C4V wudfsvc Stopped Auto BL3C4V wudfsvc Stopped Manual D7MCYP AdobeARMservice Running Auto D7MCYP AdobeARMservice Stopped Auto
Now if anyone could help output to keep the first 2 columns per server and the different values of columns 3,4 to new columns (5,6). It would also be nice if I get titles too. For example:
Server Service Before State Before Mode After State After Mode BL3C4V wudfsvc Stopped Auto Stopped Manual D7MCYP AdobeARMservice Running Auto Stopped Auto