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

346 Upvotes

91 comments sorted by

View all comments

5

u/me_again 2d ago

I think PowerShell has a lot in common with JavaScript or bash. They are the default languages for certain kinds of activity, but as languages they have quirks which are now unfixable due to back-compat concerns and which grate on developers who want a "Real Language" suitable for writing large systems.

I still remember discovering that @[] -eq @[] is neither true nor false, but an empty array 🤯. Which is explained clearly in your doc but I still maintain is a design flaw.

2

u/SupremeDictatorPaul 2d ago

Honestly, a lot of array handling in PowerShell is problematic. Like, if a function returns an array, that array gets returned. Unless the array has one object, in which case it gets unrolled. Which means every time you use a function that returns an array (outside of a pipeline), you have to wrap the function in an array to ensure that later code that expects an array doesn’t fail. There are a few situations where it simplifies code a little, but in nearly every instance for me it’s just been a hassle.

2

u/dodexahedron 2d ago edited 1d ago

There's also the -NoEnumerate switch, which is for exactly that. But using it can also be clunky.

Also, note that passing an array object through the pipeline as input to the next pipeline stage enumerates by default but, if passing that object as an explicitly named parameter (even from the pipeline), it stays an array, always.

Strongly type your parameters and write pipeline-friendly code in the first place (i.e. make use of begin, process, end, and clean as appropriate - including in ad-hoc/ in-line script blocks), and it won't be an issue.

2

u/KevMar Community Blogger 1d ago

Also, note that passing an array object through the pipeline as input to the next pipeline stage enumerates by default but, if passing that object as an explicitly named parameter (even from the pipeline), it stays an array, always.

My solution for this single item over pipeline vs passed as a parameter is to always loop over it. There are still some behavior differences to watch for when running in the pipeline vs not.

process {
    foreach ($item in $InputObject) {
        # do stuff
    }
}

1

u/dodexahedron 1d ago

That's one way. It is a lot cheaper to check first and only enumerate if you need to, as ahown in one of the about_Functions docs. Otherwise, if it is in a pipeline and you unconditionally use a foreach, you'll be creating an enumerator for one item, as many times as there are items in the pipeline, because process gets called for each one, one at a time.

You might find this pretty cool, too, for some functions.