r/PowerShell • Community Blogger • 2d ago

News Why developers hate PowerShell

https://powershellexplained.com/2026-11-24-why-developers-hate-PowerShell/?utm_medium=post&utm_content=rpowershell&utm_source=reddit

This is a post that I have been thinking about writing for a very long time now. I find that developers struggle with PowerShell in a very different way that the sysadmin learning to automate. They bring intuitions and assumptions with them from other languages that catch them off guard when they skip over the documentation. In this article I try to capture some of those experiences and misunderstandings.

I cover a lot of ground in this one: running scripts, execution policy, aliases, objects and formatting, calling functions, output and return values, unrolling, operators, case sensitivity, type conversion, truthiness, strings, scope, automatic variables, paths, encoding, errors, native commands, and classes.

While this one is targeting Software Engineers more then Systems Engineers, I would still appreciate your feedback and stories of your own frustrating experiences.

Thank you, -Kevin

343 Upvotes

89 comments sorted by

View all comments

1

u/cottonycloud 2d ago

Excellent post! Touches on most of my pain points, coming from Java, C, C++, Python. PS7 has fortunately cleaned up many of my old gripes but there are still some.

- Classes and importing are a big one. There really should be only one way to import that includes classes. I cannot think of a reason why I would not to import classes as well.

- Dynamic scoping - Sorry I just don’t like it lol. If I wanted that variable, I’d have declared it as a parameter.

- Null and errors - To me, undeclared variables should always throw an exception and I shouldn’t have to toggle strict mode.

- Aside, I wish VSCode (I guess PSScriptAnalyzer) highlighted automatic variables and could discover undeclared variables.

- Null-coalescing with variables often involve enclosing the variable as such ${var}?.method(). A bit annoying for sure.

- No “using” statement to enclose variables. Just a minor gripe here.

2

u/surfingoldelephant 1d ago edited 1d ago

Aside, I wish VSCode (I guess PSScriptAnalyzer) highlighted automatic variables

PSSA isn't responsible for syntax highlighting. It will however flag assignments to automatic variables by default. See AvoidAssignmentToAutomaticVariable.

Invoke-ScriptAnalyzer -ScriptDefinition '$input = 1'

# RuleName                             Severity ScriptName Line Message
# --------                             -------- ---------- ---- -------
# PSAvoidAssignmentToAutomaticVariable Warning             1    The Variable 'input' is an automatic variable that is built into
#                                                               PowerShell, assigning to it might have undesired side effects. If
#                                                               assignment is not by design, please use a different name.

Syntax highlighting comes from the TextMate grammar defined here. PS's TextMate grammar is pretty lacking, but it does actually include a rule for highlighting automatic variables. Most themes don't bother with that granularity, hence you typically end up with the same color for all variables. So you just have to configure a different color yourself. Here's the rule: support.variable.automatic.

This article explains how to do it in your VS Code settings.

1

u/cottonycloud 1d ago

Thank you! I just assumed there wasn't any option to highlight automatic variables lol.

1

u/KevMar Community Blogger 2d ago

I'm good about programming defensively against dynamic scope in my own stuff. It is so ingrained into my coding style that I forget about dynamic scope. Well ... until I run into someone else's code that abuses it.

And its not consistent in that Modules get their own scope (I think its actually a closure) and it doesn't pass it through to other Module calls. So things like -WhatIf don't consistently work when one module calls another module.