Compare-Object's SideIndicator property

Tagged: 

This topic contains 19 replies, has 3 voices, and was last updated by Profile photo of Al Al 7 months ago.

  • Author
    Posts
  • #60303
    Profile photo of Al
    Al
    Participant

    Can someone tell me if the object outputted by Compare-Object, when using the switch PARAMETER -PassThru, contains the pretty much useful property SideIndicator?
    The documentation says nothing about this; it even does not contain any information about the mentioned property.

  • #60304
    Profile photo of Olaf Soyk
    Olaf Soyk
    Participant

    Why don't you give it a try?

  • #60316
    Profile photo of Dan Potter
    Dan Potter
    Participant

    code shorter than your post ;D

    $a = 1..10;$b=1..15;compare $a $b -PassThru

  • #60352
    Profile photo of Al
    Al
    Participant

    I don't give a try because I'm using an Android tablet, therefore, I have to guide me solely by the *documentation*, which is pretty bad BTW( otherwise I wouldn't need to ask such question ).

    As to the code shorter than my question, it is equivalent to the documentation: any person reads the explanation, and concludes it doesn't explain what it should; it is incomplete ‼

    As you all spent your time writing and mine reading, maybe, you could pipe the cmdlet output to Get-Member and show the result, for the sake of completeness; maybe, you'd rather keep your post incomplete...

    • #60357
      Profile photo of Dan Potter
      Dan Potter
      Participant

      So you're going to learn powershell by reading the complete documentation before execution? Good luck.

    • #60367
      Profile photo of Al
      Al
      Participant

      Again, inquiring a question in my thread? Please, start your own thread with this question, and wait some reply...

      Added:
      I don't need luck, because my great understanding capacity suffices, but I do accept good luck always, why not?!

  • #60354
    Profile photo of Olaf Soyk
    Olaf Soyk
    Participant

    So the answer is 'yes'

    • #60366
      Profile photo of Al
      Al
      Participant

      Thanks. Any other NoteProperty added by PowerShell? I hope you don't mind this complementing question...

  • #60379
    Profile photo of Olaf Soyk
    Olaf Soyk
    Participant

    Of course I don't mind. Nevertheless I would like to answer with a recommendation: Wait until you have access to a Windows client and start your own researches. Powershell is a fast developing universe and it is – just like all the others – partly imperfect.

    It sounds for me like you try to learn swimming with reading a book. Sometime you will have to jump into the water and start swimming. 😉

    • #60382
      Profile photo of Al
      Al
      Participant

      Thanks. In fact, I already swam a lot in *troubled* PowerShell waters, therefore, I know how bad the documentation is: many errors and invariably incomplete. In PS, the big evil is in the details ( because the docs doesn't help ). Compare-Object is, IMO, much of the time disregarded, due to its complexity and bad doc support.
      BTW, what about my *extra* question: any other NoteProperty added to the object passed thru by PS?

  • #60393
    Profile photo of Dan Potter
    Dan Potter
    Participant

    no, it will only output the difference object. no header.

    PS C:\Users\Dan>
    PS C:\Users\Dan> $a = 1..10;$b=1..15;compare $a $b -PassThru
    11
    12
    13
    14
    15
    PS C:\Users\Dan>
    
    
    
  • #60397
    Profile photo of Olaf Soyk
    Olaf Soyk
    Participant

    Au contraire, mon capitain! 😉 😀
    That's why I recommended to do your own researches. Really often the answer to a question is 'it depends'.
    Try this when you have access to a Windows machine!

    $Process_01 = Get-Process | Select-Object -First 20 | Select-Object -Property Name,ID
    $Process_02 = Get-Process | Select-Object -First 40 | Select-Object -Property Name,ID
    Compare-Object -ReferenceObject $Process_01 -DifferenceObject $Process_02 -PassThru
    
    • #60403
      Profile photo of Dan Potter
      Dan Potter
      Participant

      Is the entire object compared or just the name in this example?

    • #60420
      Profile photo of Al
      Al
      Participant

      Again, a reply mimicking the docs: incomplete.
      You should post the output to shed some light to this thread.
      BTW, the proper way to know the elements of an object, is through the Get-Member cmdlet; so, in your code, after passing thru the Compare-Object output, pipe it to Get-Member, and copy and paste (and post) what you see in your display.

  • #60408
    Profile photo of Olaf Soyk
    Olaf Soyk
    Participant

    ... good point. Actually I don't know. At least I didn't specify. But it has the SideIndicator in the output. That's what I wanted to show. 🙂

    • #60423
      Profile photo of Al
      Al
      Participant

      You don't know, that's the point.
      But you already have your Windows computer, so, you only need to do some researches of your own, and (please), post the correct conclusions.

    • #60430
      Profile photo of Olaf Soyk
      Olaf Soyk
      Participant

      It was MY point. And I am free to say my opinion. You are not the ruler of this thread – even if you started it. So calm down and get Windows machine please. You're acting like a girl scout. 😉 😀

    • #60507
      Profile photo of Al
      Al
      Participant

      You're not the ruler, neither, so calm down you. You're acting like an old master hysteric girl scout.

  • #60412
    Profile photo of Dan Potter
    Dan Potter
    Participant

    I verified it is just the name using chrome as a process that fluctuates considerably.

    I typically use $array1 | ? {$_ -notin $array2}. Just seems easier to me.

    • #60426
      Profile photo of Al
      Al
      Participant

      No, it is not easier.
      First, because your code snippet *implies* you need to implement a loop to iterate thru all elements ( diff cmdlet does it automatically, thru compiled code ).
      Second, you are comparing PSCustomObject's, and FOR SURE, you'll want to compare some property BY VALUE ( and not those objects by reference ).

You must be logged in to reply to this topic.