Author Posts

January 10, 2018 at 9:42 pm

Dear PowerShell experts,

I am currently getting started in PowerShell and there's still much to learn. I have written a short script that compares two paths $a and $b and then outputs all the absolute paths in $b which are files that either do not exist in $a or are files which have different content than in $a.

As PowerShell seems to be very serious about the correct verbs [1], I am unsure of what kind of verb this behaviour would be. I think I should pick a verb from the common section and among those are Get, Select or maybe Join. Compare (from the Data section) also makes sense to me.

Can you please explain me what the right choice would be?

Many thanks in advance.

[1] https://msdn.microsoft.com/en-us/library/ms714428(v=vs.85).aspx

January 10, 2018 at 9:45 pm

Think about what the output is, and whether any system configuration change is taking place. If all you're doing is analyzing and outputting objects that demonstrate a difference, then Compare- would be the usual verb. Compare-PathContents, perhaps.

January 11, 2018 at 8:10 pm

Thank you very much.