4 ms·
This is not an example of evolving syntax. It's just a bunch of parameter sets added to Where-Object. New syntax is the -in operator for example (reverse of -co
by ygra 12y ago
This is not an example of evolving syntax. It's just a bunch of parameter sets added to Where-Object. New syntax is the -in operator for example (reverse of -contains).
However, I find myself using the new parameter sets for Where-Object very infrequently. Since they can only model
Property -Operator Value
their use is limited to certain operations, which I find myself to need not that often. And if the conditions get more complex I need to write a scriptblock anyway, having to refactor your former form into the latter.
- tbyehl 12y agoPoint being that it's easy to write a script that works fine on v3/4 but fails when run on v2, without doing something incredibly obvious like using cmdlets or modules that didn't ship with v2. Here is a by-no-means-comprehensive list of potential gotchas: • Operation Statements vs Script Blocks • Several new operators • Changes to $PSScriptRoot and $MyInvocation • Stop parsing symbol --% • Ordered dictionaries • New redirection operators • Count and Length properties added to "arrays" of zero or one • Retrieving a property from a collection that only exists in the individual items returns the value from all items. • BadNumericConstant