Hacker News new | ask | show | jobs
by d3Xt3r 43 days ago
Windows sysadmin here. PowerShell has been great for a long time, well, since at least v5.1, when they finally fixed many of the annoying issues and limitations of earlier versions. I practically live in it the whole day - 90%+ of my work life is in PowerShell these days.

But I question its utility on other platforms, because a lot of the things that makes PowerShell cool on Windows doesn't actually work in Linux or macOS.

Eg: Get-Service (and associated cmdlets). Very handy cmdlet that I use all the time on Windows. On Linux, you'd expect that it'd work with systemd units, but no, that command doesn't exist on the Linux version. Same with Get-NetAdapter, or Get-NetTCPConnection, or Get-Disk and so many other handy cmdlets that I use all the time on Windows, are all missing.

Yet, some cmdlets do exist, like Get-Process or Get-Uptime etc, so I don't understand why many of the commonly used Windows cmdlets haven't been ported over.

Another annoying quirk is how PowerShell on *nix hands off some of the built-in aliases to their native versions. Like on Windows, I always use 'ls' because ain't nobody got time to type Get-ChildItem. Unfortunately when I run this on *nix PS, it runs the native version. And this is a problem because when I pipe 'ls' into a for loop or another cmdlet for further processing, it naturally, doesn't work. To make things worse, this native-or-alias decision making isn't even consistent. Like 'pwd' for example actually runs the PowerShell version, whereas 'echo' runs the native version.

Basically, as much as I love PowerShell on Windows, on *nix it is very annoying to work with. I would much rather work with native *nix shells and scripting languages. And if I really wanted the structured output of PS, I would run Nushell instead, which is far more consistent and useful than the half-baked product that *nix PowerShell is.

4 comments

I know linux is prided for it's low-level C code, but linux is desperately missing an object-oriented API. C# flavor below:

var service = thisSystem.GetService("rss-news-feed");

service.SetRefresh(TimeSpan.FromHours(1));

service. //<----now we can autocomplete everything a service can do.

Edit: it's a travesty that OO get's shoehorned into architectural design of large systems whereas it would be ideally suited in a Nix-like API for interacting with operating systems which are 'solved'.

This is not true. There is dbus these days. There was CORBA and friends in days when COM was new.
> On Linux, you'd expect that it'd work with systemd units

This seems quite hard to implement. There are also other init systems that PowerShell may chose to not support but then they'd need to add a disclaimer for supported systems. Also systemd is quite complex with its setup of user defined units, overlays etc.

> There are also other init systems that PowerShell may chose to not support but then they'd need to add a disclaimer

That's not really a concern, I mean systemd is by far the most popular init system, and especially in a situation/environment where one might choose to run PowerShell it's highly unlikely that you'd be running any other init. Like if you're the kind who'd prefer dinit or S6 or something, you wouldn't even consider running a "bloated" shell like PowerShell in the first palace.

So there's no need to add a disclaimer. Microsoft can just deal with it the same way they deal with distro support - they officialy support Ubuntu but for others you're on your own, although they do provide tar.gz packages.

And yes, systemd is indeed quite complex but there's no reason it can't be translated across to PowerShell lingo, at least parts that makes sense.

Eg:

    Get-Service -Name <svc> -> systemctl status <svc>
    Start-Service -Name <svc> -> systemctl start <svc>
    Stop-Service -Name <svc> -> systemctl stop <svc>
    Set-Service <svc> -StartupType Disabled -> systemctl mask <svc>
And so on.

They've had six+ years to do perfect this, which is plenty of time - if they were really serious in pitching PowerShell as a true cross-platform shell. But it seems like they don't really care, especially now that they've captured most Linux users by means of WSL2, so it makes more sense for them to invest in that rather than invest in cross-platform parity in PowerShell.

> Also systemd is quite complex with its setup of user defined units, overlays etc.

But Microsoft has the design documents, so it shouldn't be a problem to implement this functionality. /s

There’s also gci and dir. Both work as an alias for Get-ChildItem in all supported platforms. No need to use ls.
ls is one letter shorter, and it's part of my muscle memory.
sal ls gci >> $PROFILE

its faster then this discussion.

ls was just an example. There's tons more. I'm not going to test each and every command/alias/cmdlet and fix it so that it reaches parity with the Windows version. This is something Microsoft should have done so out of the box.
You are aware that there exist people who can want the opposite?

You can ask AI now to do it for you, you can probably find easily something somebody already did. It would have been nice if MS offered something that people can choose to install, but its far from a deal breaker like you seem to make it to be.

There is nothing to test, you want collection of aliases, that is trivial.

FWIW, they tried some things like https://github.com/PowerShell/Crescendo

As I said before, it's not just the aliases, it's all the cmdlets that are missing too, there's too many of them to list.

And why should I waste my AI tokens on fixing Microsoft's product? I'd much rather contribute my resources towards a fully open-source, indie project.

You can fix that very easily in your linux profile (make ls call gci and not native tool). Just add alias in your profile. You cant really complain about the absence of some cmdlets on linux, and they are trivially easy to get implemented (or wrap native tools).
I shouldn't have to do Microsoft's job. My point is that they put out a half-baked, nerfed shell for Linux, which is not cool. If they really wanted PowerShell to be taken as a serious, cross-platform shell, they should aim for 1-1 parity with the Windows version, or at least close to it. It's been 6 years since v7 came out, they've had plenty of time to do it.

If you want me to fix up Microsoft's slop, I'd rather contribute to a proper indie FLOSS project, like Nushell or something.

Such a drama without a reason.

Its not slop for one. Take a look at repo and its practices. Its mind blowing and predates AI.

Nushell is nice, but lets not get carried away - it is decade away from pwsh, and suffers from the same things you complained, with language and semantics that are not intutive as pwsh's and not nearly as complete. Besides, so many 3rd party supports pwsh like Sql Server, VMware etc.

I agree that MS should push it way more and make Linux variant even better. The problem is that pwsh hardly surived at MS (cudos to Snover for being stuborn and worked against his position at MS to make it happen), and that needs some opinionated people working in MS who can fight this battle (I could honestly dedicate my life to this, I offer my services, for both pwsh and Windows, Microsoft!).

Deployment, deployment, deployment.

The web was successful because the installation cost was 0.

That is my only complaint really. Lets make it there... I beleive main offender is .net, but also main feature enabler.