Powershell still sucks

Powershell is a great command line shell, if you all you know is cmd and batch. There are so many things it is missing when trying to compete with current Unix shells such as Bash, and while some of them have semi-working workarounds, many are sorely missing.

My pet peeves are:

  • A decent pager. “more” is basically at the same stage it was when I started working in MS-DOS 3.30, and it is nowhere near the functionality of “less”1.
  • Persistent history. I’ve seen some workarounds but couldn’t get any of them to work properly.

Both of these features have been available to me since I started working with Linux in 1995, and it is really difficult living without them in MS-world. A decent terminal emulator will be nice too – the Powershell box has advantage over the cmd.exe box in that it is blue – other then that they are both in the same sorry state that the “dos box” of Windows 3 fame was at. I’m using “Console 2” to get some useful work done, but it too leaves much to be desired.

Also, startup is so.. fscking.. slow.. Starting Powershell on a brand new machine (with no per-session user scripts) can take as much as 3 seconds. Those are minutes of my life everyday that I would never get back.

  1. and I’m not talking about the built-in editor, just being able to “page up” would have been nice []

18 Responses to “Powershell still sucks”

  1. John:

    You are right. Powershell sucks. It isn’t as powerful as a full compiled language and is not quick to use like vbscript or command-line scripting. So it falls in between and doesn’t really have a nitch other than MS wants it to be the scripting language of choice for Windows (for now). MS is forcing this pile of non-intuitive garbage on it’s customers as a “service”.

    • Oded:

      I am coming to this from the perspective of a UN*X user, which I think is the target audience for this product – Microsoft wants to entice administrators who are used to the UN*X way: powerful shell languages allowing you to do anything from the console – remote access, administer, script and even build complete applications using a simple language that is fast to work with.

      Powershell looks more like bash/ksh/csh than any other Microsoft technology (excuse me, but CMD batch processing is a horrible pile of junk that hasn’t gained a single feature since MS-DOS 7.0 days, and VBScript as a system administration language is a sad joke), but when I use it I am mostly reminded in how much MS-Windows is not UN*X – Powershell is not simple, it is not fast, and it is not comfortable.

      It does offer remote shell -like access (using WinRM with WMF 3.0), which while could be easier to set up and still suffers from all the problems of Powershell itself, is still so much better than needing to open a full screen RDP session every time you want to manage a remote machine.

  2. KPB:

    I have to agree that powershell sucks. I’ve been in the IT industry for over 35 years. It’s laughable that people thing Cobol was horrible. I’d take Cobol over powershell any day!

  3. Berferd:

    It is pretty bad when the end user cannot double click and run the script.

  4. Jon Retting:

    Powershell is ballz. For example try using to just return/store you active NIC’s ipv4 address. Just the IP, nothing more, nothing less. You either end up with a cluster fuck of powershell code with well over 20 lines. Or you resorted to bringing in Vbscript and CMD code. Just strpin the brackets from “{0.0.0.0}” is a ridiculous task. Microsoft decided it smart to have 90% of their shitlets useless, while deeming “Get-PrimaryNic -IPv4” not worthy.

    Powershell’s stupidity is mind-numbing. You might as well complete the task with the GUI like clicking on 20+ Remote machines, open a remote computer management windows. Then for each system update the drivers for a device. Then you find out for some shit reason, hidden in layers of chaotic unsearchable nonsense, microsoft has chosen to remove remote device management. So they release cmdshitlets to manage/replace it. This means you will now spend twice the amount of time tooling around with the new shitlets, and finally conjure up a useful set of tools for applying them. Then powershit happens and you just don’t give a crap.

    If you like writing needless pointless code all day, in order to accomplish the most basic of Tasks Powershit is for you. If you enjoy network news, write batch/cmd scripts, think vbscript is good stuff, and prefer using a laptop to work on, and prefer web-browser tabs on above the address bar, Powershit is totally for you!

    Meanwhile people who actually do cool stuff use a Bourne based glue, and bash it like its hot.

    • Oded:

      Totally Agree.

      Other things I managed to get annoyed about with PowerShell, since this article was written:

      • TAB completion cycles through options instead of showing a list – meaning you can never be sure of what options are available other then the first, and if you happen to hit any key after the TAB, you have to backspace and try again (granted, this is not new for PS, it was bad like that in cmd.exe).
      • The “Verb-Object” syntax makes it really hard to find what you want with TAB completion. .e.g I want a list of services: Get[tab], and you have to cycle through all the things you can get until you get to Get-Service at “S”. UN*X is more intuitive with “object verb” syntax: service[tab] -> list of services -> [tab] -> operations on each service.
      • Default “execution policy” doesn’t actually allow you to use PS scripts. If you create helper scripts (because the command line syntax is horrible mess) and run them from the console, then you either have to change the default policy on all the systems you manage, or use contrived “bypass” mode.
      • As Berferd mentioned – forget about double clicking a script – it cannot be made to work.
      • Logic operations use weird perl-like syntax (-eq instead of ==) which is hard to remember.
      • Automatic conversion of single item lists into a single value, but not vice versa – ruins more carefully thought out scripts than any other programming mistake.
      • Automatic parsing of command line arguments for scripts is complex, unnecessarily verbose, inflexible and cannot be turned off!
  5. Avian:

    * “A decent pager” – did you know that you can use less in Powershell? It’s available in packages like GnuWin and msysgit. If you use the Chocolatey package manager, you can install it by simply entering the command “cinst GnuWin”. This will not only get you less, but also grep, sed, cut, awk, etc.

    * “Persistent history” – I don’t know why this is not present either, but it was pretty trivial to add – I simply put these two lines into my profile:

    function bye {Get-History -Count 1KB |Export-CSV ~\PowerShell\history.csv; exit }
    if (Test-path ~\PowerShell\History.csv){Import-CSV ~\PowerShell\History.csv | Add-History}

    * startup – what version are you using? This was previously a problem for me but as of Powershell 3.0, it is as fast to start up as cmd or bash for me.

    * Active NIC’s IPv4 address: Simple command: (Get-NetIPConfiguration)[0].IPv4Address

    Get-NetIPConfiguration returns your network interfaces in order of priority. The first one is used for general traffic, but depending on how you configured your network, you may have certain IP ranges routed through other NICs.

    * “TAB completion cycles through options instead of showing a list” – hit F7

    * “Logic operations use weird perl-like syntax (-eq instead of ==) which is hard to remember.” – These are taken from long-standing Unix conventions (see the “test” command on *nix for example), and are done to avoid conflicting with the standard shell script operators ( for redirecting, && for command separation, | for piping, etc). This perfectly fits what I expect a shell to do after using cmd, bash, ksh, zsh, etc.

    * “Automatic conversion of single item lists into a single value, but not vice versa” – I’m not sure what you mean by this, but Powershell does actually allow you to call properties on a list of objects as if it was a single item. For example: [string](get-netipconfiguration).ipv4address will return a concatenated list of the IP addresses of all current network interfaces.

    * “Automatic parsing of command line arguments for scripts is complex, unnecessarily verbose, inflexible and cannot be turned off!” – except it is flexible and powerfull, and *can* be turned off. If you add –% to any command, anything after that will be passed unparsed to the command you are calling.

    * “Default “execution policy” doesn’t actually allow you to use PS scripts.” – MS defaults to being as secure as possible given the history of exploit attempts against their software. This is trivial to turn off.

    I have used bash and powershell for many years now (along with various other shells), and I can safely say that powershell is more powerful than any of its competitors. A full-fledged object pipeline and the tools to make use of it is a hugely powerful tool in the hands of anyone who learns how to wield it.

    • Oded:

      * pager: granted. I believe that if MS are seriously targeting UN*X sysadmins, then they should have these tools out of the box, especially if they want me to ship powershell scripts to my customers. But still – yes, being available for installation by a cumbersome process (set up a package manager, install a large framework, etc) is kind of solving that problem.

      * history: when I last tried it, the Googleable KB to do it was way more complicated, and as a result your old history was (not really reliably) available from Get-History, but you couldn’t use the UP key to get to it.

      * startup time: I was working on PS3. Recently tried PS 4 and it is marginally better, but > 1 sec startup time is not acceptable.

      * NIC IP: nice, didn’t know that.

      * completion: F7 shows a history list, it doesn’t list completions. For example, if I type “dir c:\P” then I want to press a key and to get a list of all directories that start with “P” under “C:\”, so I can choose one and continue to edit the command. Bash does this, Zsh does this very well (you actually get a menu to select from), Powershell does this horribly bad.

      * Logic operations: you messed it up – “-eq” is supported by test, but only for integers. String comparison must use “=”, and it also works for numbers (at least when identity is the same as equality, which it is for integers).

      * Single item lists: hmm – I didn’t realize that this is what its doing. Now it makes more sense.

      * command line arguments: my gripe isn’t that you can turn it off, but that to get something useful done you have to go through a lot of hoops. I’m all for lots of power, I just want to not have to do the heavy lifting if I want just a bit of power – which the “$” syntax of UN*X shells allows me. And getting my users to remember to use obtuse syntax like “-%” is not an alternative.

      * execution policy: It is not trivial to turn off. And let me explain what I mean by “trivial”: things that a non-programmer, possibly non-admin user, can figure out themselves how to do when you ship them a product based on Powershell scripts.

      Regarding your summary – yes, Powershell is quite powerful, possibly more powerful than UN*X alternatives, but you pay for that power with huge complexity and the inability to use the shell as a product integration tool for customers. This is a price I’m not willing to pay.

      • Avian:

        * “I believe that if MS are seriously targeting UN*X sysadmins, then they should have these tools out of the box” – it would actually be illegal for them to distribute less out of the box given the copyleft license. They could have duplicated its functionality I guess but I don’t see the point.

        chocolatey is actually very easy to install (both automated or manually), but Windows should have had its own package manager a long time ago. It will finally have one in Windows 10 with OneGet.

        * history: it Just Works(TM) for me but I can’t argue with your experience. I like the fact that Powershell doesn’t force you to load history from a single source, since I keep separate history for different environments I frequently use, but it would have been ideal for them to provide a function (like they do for tab expansion and the prompt) that defaults to loading a universal history but can be overridden as desired.

        * startup time: my machine has an HDD rather than an SSD and it still loads instantly for me (Win 8.1), but again your experience may be different.

        *completion: Yes, straight powershell is remiss in this regard, due to the fact that they still haven’t upgraded their terminal UI. powershell_ise does nice tab completion and PowerTab adds proper completion to straight powershell, albeit hacky if you are using the built-in terminal app.

        * Logic operations: my bad on that… but the actual rules for when you can use what operator (as well as some of the general syntax) are pretty convoluted in bash too.

        * command line arguments: I rarely have to use –% in normal use cases, even when calling executable utilities. In fact I can’t remember a recent time when the standard command line parsing didn’t work other than with imagemagick, which requires the ` character in its syntax.

        * execution policy: It even tells you in the prompt how to turn it off – all you have to do is copy-paste what it gives you.

        “yes, Powershell is quite powerful, possibly more powerful than UN*X alternatives, but you pay for that power with huge complexity ”

        bash has its own kind of complexity, but you’re just used to it by now – and arguably maybe I just plain prefer Powershell’s kind. But ultimately it would be nice to have no issues at all.

      • Bob:

        This is very reminiscent of typical Windows solutions, “just install xyz and it’s somewhat useful.” I think people who defend the Microsoft environment don’t know Unix as a point of reference and therefore don’t understand the truly crippled nature of Windows. It’s like walking around on hot sand not knowing there is lush grass around the corner. Unix is often graceful where Windows is often clunky. Unix is often fast where Windows is usually slow. It’s interesting to watch my company switch from Windows Server to CentOS. The engineers were wary at first but now they are saying things like “you know what, this is way better”. I want to kill myself opening up RDP windows and clicking through screens. It takes FOREVER. I hate Power Shell based on my experiences so far. Why should I invest time in something that only runs on the worst operating system? Hello Microsoft, the world is using SSH, modern terminals, and standard programming languages, get on board the train.

        • Avian:

          I work with Linux every day – and I have to install plenty of things there as well to make it do what I need it to do. Fortunately in both cases, there are mature package managers to make it super easy to install what I need.

          It sounds like the engineers at your company were stuck in their old mindset of using GUIs to administrate everything. You do not need a GUI to administrate Windows Server, and ought to not install the UI components in Windows Server at all unless you’re operating a terminal server for a thin client or something. Of course they’ll find it better when switching from a GUI to the command line, but they could have done that a long time ago while staying on Windows.

          Powershell is even more capable of remote administration than bash+SSH is. You can manipulate multiple remote connections at once and use DSC or other built-in workflow tools to deploy changes to thousands of machines with a simple script.

          If you would take the time to learn Powershell well, you would come to appreciate the advantages of an object-based shell over the traditional text-and-binary shells.

          • Paul:

            “Even more capable of remote administration than bash+SSH is.”

            Unless you can demonstrate straightforward SCP functionality built in to powershell your claim is laughable. The easiest process I’ve found to accomplish this is:
            “`
            $cred = Get-Credential -UserName whateverDumbUser -Message “m”

            $sesh = New-PSSession -Credential $cred -ComputerName whateverHatedServer
            $file = [System.IO.File]::ReadAllBytes(“C:\temp\some_ass_file.zip”)
            Invoke-Command -session $sesh -ArgumentList $file -ScriptBlock {[System.IO.File]::WriteAllBytes(“C:\some_ass_file.zip”, $args)}
            “`

  6. Script Day: Cloud-init for MS-Windows, The Poor Man’s Version :: Things n' Stuff:

    […] going to use the PowerShell scripting language to automate the setup. It’s true that I hate PowerShell, it is still many orders of magnitude better than the other scripting language available on […]

  7. NMac:

    I just had to post somewhere about this. I’m in the process of trying to use Powershell for a SCOM issue and I’m giving up on it. “Power”Shell has made my days longer and my nights more restless. I have NEVER used PowerShell for anything unless I just HAD to. And when I do need it, it takes an hour to find the right module and find the right syntax to make one little command work. And then in some cases the final result is, it doesn’t work. In my case today, I’m going directly to the SQL database to fix the problem.
    All of the frustrations have been said over and over, but I just had to release some tension and this looked like a good place to do it!

    • Oded:

      Yep, as good a place as any 🙂

      I should probably repost something about powershell, but as I haven’t had the misfortune to use it for the last 2 years (since I’m back to 100% Linux use), I don’t feel inclined to expose myself to that abuse again…

  8. The Mighty Bash Shell on Windows 10??? | Geek and Technology stuff:

    […] A decent pager. “more” is basically at the same stage it was when I started working in MS-DOS 3.30, and it is nowhere near the functionality of “less”(1). […]

  9. kirm:

    I thought it was just me. I’ve been using Linux at home for about 10 years and I’ve been in the computer industry for about 15. People say, rightly so, that Linux can be difficult to use and you a have to resort to the command line. But that command line is oh so smooth and easy to use. Try that with Powershell. I’ve been using it at work a bit now and as someone above said, WHAT A HASSLE! Ordinary cmd.exe is different in many respects…I don’t know why. Try to escape a space with cmd.exe. Use ^ and then a space, right? Try that with Powershell. NOPE! It doesn’t work. You have to used other means. With *nix it’s so easy and powerful. Powershell is just another overrated MS product.

    • Oded:

      Well, Powershell is a proper shell in linux terms – unlike the dreaded cmd.exe (command.com of yore) which is just a glorified batch processor and not even a good one at that. With Powershell you can do proper scripting and – one thing it has over cmd.exe – there is no different language for scripts and for the command line, so you can actually try things on the command line and then write them into a script file.

      So in that regard, Powershell is a huge step forward that brings Microsoft Windows from being 30 years outdated to almost up to par with the state of the art of operating systems – at least when doing feature comparison. On the other hand, the implementation is horribly broken, very overly complicated and way to jarring for immigrants from UNIX land than what the Microsoft executives wanted or would have you believe.

Leave a Reply