none
In Side Indicator property of Compare-Object cmdlet, is it possible to give names like present,missing,same instead of ==, =>, <= RRS feed

  • Question

  • Hi Team,

    I am comparing two text files which contains sets of processes taken at two different times.

    I have taken the result of comparison in the form of HTML file.

    I can see the Side Indicators denoting whether the information is present in both files as "==", only in reference object as "=>" and only in different object as "<=".

    My question is whether there is any possibility to provide names like present,missing,same instead of ==, =>, <= 

    Wednesday, June 20, 2018 4:16 AM

Answers

  • Use  calculated property.

    $choices = @{'==' = 'Same';'=>'='missing';'<='='present'}

    $objectcollection | select @{n='Status';e={$choices[$_.SideIndicator]}}

    help select-object -online


    \_(ツ)_/

    Wednesday, June 20, 2018 5:43 AM

All replies

  • Use  calculated property.

    $choices = @{'==' = 'Same';'=>'='missing';'<='='present'}

    $objectcollection | select @{n='Status';e={$choices[$_.SideIndicator]}}

    help select-object -online


    \_(ツ)_/

    Wednesday, June 20, 2018 5:43 AM
  • Hi JRV Consultant,

    Below is my comparison script

    **************************

    $fileA = "D:\Process.txt"

    $fileB = "D:\Process1.txt"

    compare-object (get-content $FileA) (get-content $FileB) -IncludeEqual | ConvertTo-Html | Out-File -FilePath D:\Difference.html

    ***************************

    Can you help me in appending the calculated property mentioned by you in my script? 

    I tried using it but the input object is not appearing and also side indicator alone appears with the output replaced as same, missing, present.

    Previously the Input object with process name appeared in one column and Side Indicator appeared in another column.

    Wednesday, June 20, 2018 9:03 AM
  • Thank you JRV Consultant. I got my desired output :) 
    Wednesday, June 20, 2018 9:26 AM