PowerShell cmdlet to compare two different objects
Ever has a need to find out what process an application is running as. PowerShell can help.
Let's see you want to know what process AIM running under, before you start AIM, do this:
$x = get-process
Then start AIM and grab the second snapshot:
$y = Get-process
Now you can get the difference by doing this:
Compare-object $x $Y
The output will be something like this:
InputObject SideIndicator
----------- -------------
System.Diagnostics.Process (aim6) =>
System.Diagnostics.Process (anotify) =>
System.Diagnostics.Process (aolsoftware) =>
System.Diagnostics.Process (aolsoftware) =>
System.Diagnostics.Process (EXCEL) <=
The => sign indicates that the AIM processes were found in the second object, but not found in the first object. The <= sign indicates that the EXCEL process was found in
the first object not the second object(I closed EXCEL before I grab the second set).
You could use the same technique to compare process or eventlog etc on different computer or the same computer at different time.
You can also use this cmdlet to compare two text files
compare-object (type c:\temp\server1.txt) (type c:\temp\server2.txt)
InputObject SideIndicator
----------- -------------
IPAddress=192.168.1.11 =>
IPAddress=192.168.1.10 <=
MACAddress=00.11.28.75.DF.DA =>
MACAddress=00.11.28.75.CD.48 <=
ComputerName=SERVER2 =>
ComputerName=SERVER1 <=
.
.
.
What can I say? PowerShell Rocks!