r/PowerShell • Community Blogger • 14h 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

223 Upvotes

70 comments sorted by

View all comments

14

u/Solonotix 13h ago

I hit almost every single thing you've mentioned, lol. As a developer on Windows, PowerShell is my go-to for scripted actions, and I have been bitten so many times by these various gotchas. I like to think I'm on the other side of this bell-curve, though, where I'm now starting to use these eccentricities rather than being caught unawares.

For instance, the gotcha about multiple return values in a function scope. That's just how pipelines work. You want to make a lazy-ish pipeline? Just allow a value to be returned without a variable to capture it (and no return keyword). On the caller side, they can abort that execution with ... | Select-Object -First ... and you didn't even need to account for it.

The exception there, of course, being that you might have a disposable resource like an open file or connection. The gotcha I then hit (feel free to add this to your article) was learning that the End { ... } block does not work like you might expect, since internally PowerShell is calling the blocks Begin { ... } then Process { ... } then End { ... } with an implicit End { ... } block if you omit all of them. Side note, the special function keyword Filter has an implicit Process { ... } block instead. Anyway, all of that to say that a disposable resource can now be safely handled in a Clean { ... } block which will always execute upon exit, even when something else aborts the processing of a function/command.

This was a really big lesson for me when I was trying to do a TestRail upgrade (that royally sucked). Had to do a lot of database calls and relate it back to the file system, and I had already uninstalled all of the crap needed to complete their install instructions (e.g. Python 2.7, JDK 8). So, I dropped down into the .NET side of things and got into using [System.Data.SqlClient]. My first hitch was that lingering open cursor from one function call, and it was going to prevent subsequent queries from being run because the result set hadn't been disposed of. The Clean { ... } block was only added in PowerShell v7.3 so I shudder to think what the code would have looked like prior to this. I probably would have dropped into a C# class file and imported it with Add-Type but that begets its own realm of troubles lol

6

u/KevMar Community Blogger 13h ago

Nice call out. I absolutely need to find a place for that in my article.

5

u/Solonotix 12h ago edited 9h ago

Do you happen to have any articles covering the weirdness and use cases for the various common types in PowerShell? I tend to use explicit type annotations for things, and I've noticed differences in how some things are handled, as well as what AI agents recommend.

For instance, the [ordered]@{} type. I used Get-Member on it, and it said it was Something like [Systems.Collections.OrderedDictionary] (might have the wrong type), but it behaves differently from that explicit type. It's like [ordered] is its own discrete thing that works with the object syntax. This of course is different than the default result of the declaration @{ ... } which is [System.Collections.HashTable] as well as the ubiquitous [PSCustomObject]@{ ... }

5

u/KevMar Community Blogger 12h ago

I don't recall if my hastable article covers some of that. I remember fighting with [ordered],[hashtable], and $PSBoundParameters not having consistent methods across all three for checking if a key exists at one point. I think my solution was to cast everything to IDictionary at the time. I definitely use IDictionary instead of hashtable when strongly typing parameters because of that.

3

u/surfingoldelephant 7h ago edited 6h ago

but it behaves differently from that explicit type

Because [ordered] is special-cased in the parser (similarly with [pscustomobject] and [ref]).

There's a semantic check that prevents anything other than a hash table literal following it because it's not a real type in Windows PowerShell. It's kinda like an attribute (but not really) that tells PS to produce a case-insensitive Collections.Specialized.OrderedDictionary instance. That dictionary type by default is case-sensitive.

[ordered] was added as type accelerator in PS v7, hence you can do [ordered]::new() in that version, which is the exact same as [Collections.Specialized.OrderedDictionary]::new(). But with conversion expressions, you can still only do [ordered] @{} because the semantic check that prevents anything else is still in place.

Also, side note, there are slightly different conversion rules depending on whether you type-constrain or cast. For example, $var = [bool] '' is fine, but [bool] $var = '' is not. Something to watch out for if you type-constrain a lot.