Author Posts

December 16, 2016 at 7:23 am

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.

December 16, 2016 at 10:25 am

Why don't you give it a try?

December 16, 2016 at 2:17 pm

code shorter than your post ;D

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

December 16, 2016 at 5:46 pm

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...

December 16, 2016 at 5:53 pm

So the answer is 'yes'

December 16, 2016 at 6:20 pm

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

December 16, 2016 at 8:30 pm

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

December 16, 2016 at 8:32 pm

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

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

December 16, 2016 at 9:40 pm

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. 😉

December 16, 2016 at 10:49 pm

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?

December 17, 2016 at 11:56 am

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
PS C:\Users\Dan>

December 17, 2016 at 2:43 pm

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

December 17, 2016 at 7:42 pm

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

December 17, 2016 at 10:03 pm

... 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. 🙂

December 18, 2016 at 4:48 pm

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.

December 19, 2016 at 12:21 am

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.

December 19, 2016 at 12:29 am

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.

December 19, 2016 at 12:34 am

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 ).

December 19, 2016 at 1:22 am

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. 😉 😀

December 19, 2016 at 10:38 pm

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