Top five gotchas when learning PowerShell

Here is my list of the top five gotchas when learning Windows PowerShell.

5. PowerShell will not run scripts by default.

4. PowerShell requires . to run a script in the current directory.

3. PowerShell uses -eq, -gt, etc. for comparison operators.

2. PowerShell uses backquote as the escape character.

1. PowerShell separates function arguments with spaces, not commas.

See PowerShell gotchas for more details and an explanation for why PowerShell made the design decisions it did. As surprising as these features are, there are good reasons for each.

One thought on “Top five gotchas when learning PowerShell

  1. I agree with all except #2. I’ve never had nor heard of many issues with ` as an escape character and thank goodness they didn’t use as an escape character (like in Korn shell). One gotcha that I would consider perhaps in the top five is calling out to external apps that take parameters. Sometimes PowerShell’s parsing gets in the way like if your parameters use semi-colon e.g. /workspace:hillr1;hillr. PoSh sees the semi-colon as a statement separator and considers hillr the start of a new command. Ugh, this has caused me and a lot of folks grief (which is why we added echoargs.exe to PSCX). Another popular gotcha is using expressions within double quotes. I see folks doing this “Host version is $host.version” not realizing that it should be “Host version is $($host.version)”. Just my 2 cents. BTW good stuff you’re writing on Posh. Keep it up!

Comments are closed.