compare output command

Hello Everyone,

I am wondering what it would be the best way to achieve the following.
To save the output of a command and being able to compare it at a later time to see if there is any diference between the running configuration and the one stored.

What I have attempted so far was to do a export-clixml and then do a compare-object but this doesnt seem to work with the type of output i am getting from this command.

The output generated by this cmdlet is in the following format:

EnabledOnDirectAccess : False
Farms : {}
Zones : {}
NeverLaunchThroughGateway : False
Key : 18d0d30f-3843-4da3-9547-44a164210758
Name : TransferNSGW
Address :
SessionReliability : True
RequestTicketTwoSTAs : False
SecureTicketAuthorityUrls : {http://172.22.95.125/scripts/ctxsta.dll, http://172.22.95.110/scripts/ctxsta.dll}
StasBypassDuration : 01:00:00
StasUseLoadBalancing : True
Id : 18d0d30f-3843-4da3-9547-44a164210758

thanks in advance
Cheers,
J

I am using a similar way to check if a folder with installation files contains the expected files. I create a list with the relative path and file name and a hash value and compare it with the same list I created before and exported with export-clixml.

Why shouldn’t it work? If you’d show your code we might help.

Hi, @jacobo
If you want to compare the name of files existing in a specific folder, at 2 specific times, then, the simplest way is this:

$1 = @(dir $folderA -file).fullname   # this is the reference object
$2 = @(dir $folderA -file).fullname  # this is the difference object, computed at any later time
diff $1 $2   # the difference between the 2 objects is computed, and presented on the display

If you need to, you can use the -PassThru switch PARAMETER to keep processing the result, maybe, in a pipeline. Also, you don’t need any further processing, after you grab the name of the files ( just compare them ).

Maybe, you can apply the same technique to your problem.
:black_small_square:

Hello,

Thanks for your replies.
As i posted in the first post, the output it generates this cmdlet get-stfstoreservice is shows a list of values.

I run the saved config against the run config with compare-object without parameters i take the following output, but it doesnt show where the difference is.

diff ((Import-Clixml .\gateway4.xml).gateways) (Get-STFStoreService | select -ExpandProperty gateways) 

InputObject                                                                 SideIndicator                                                              
-----------                                                                 -------------                                                              
TransferNSGW                                                                =>                                                                         
TransferNSGW                                                                <=     

If i select particular properties, for instance i see they match and they are the same.

diff ((Import-Clixml .\gateway4.xml).gateways) (Get-STFStoreService | select -ExpandProperty gateways) -Property key,id,EnabledOnDirectAccess -IncludeEqual

key                                   id                                                    EnabledOnDirectAccess SideIndicator                        
---                                   --                                                    --------------------- -------------                        
18d0d30f-3843-4da3-9547-44a164210758  18d0d30f-3843-4da3-9547-44a164210758                                  False ==                

How i could run it so it goes thru all the properties and highlights those which are different?

Thanks
Jacobo

You could try this:

$1=@(gc .\MyFirstExport.XML)
$2=@(gc .\MySecondExport.XML)
diff $1 $2

Notice that the XML files are read as TXT.
:black_small_square:

Hello,

In the end it was managed using the following

diff (((Import-Clixml .\gateway4.xml).gateways | convertto-json ) -split "`n" ) ((Get-STFStoreService | select -ExpandProperty gateways | convertto-json ) -split "`n")

thanks everyone for the replies.

cheers,
Jacobo.