In the comments section of a recent post I found out that Windows PowerShell had been ported to Linux. Had no clue it was a thing.

Went looking and found this old article attempting to explain why they did it. Not remotely interested in giving up Bash for PowerShell, but I thought it was interesting enough to share. The article seems to be from 2016.

I have never been more tempted to check the NSFW box, but I’ll leave it open for now unless a mod complains. :-D

  • Bronstein_Tardigrade@lemmygrad.ml
    link
    fedilink
    arrow-up
    5
    ·
    4 days ago

    All I remember is the years of M$ using lawsuits and FOSS to try and kill Linux. Using anything from Windoze is like saying, yeah, but the Nazi built some good stuff too. M$ tried to murder our baby, and should never be forgiven nor trusted.

  • enemenemu@lemm.ee
    link
    fedilink
    arrow-up
    7
    ·
    4 days ago

    In short: microsoft was afraid of losing devs to linux due to an increase in linux servers.

    • BrianTheeBiscuiteer@lemmy.world
      link
      fedilink
      arrow-up
      4
      ·
      edit-2
      3 days ago

      How does this help though? If anything they would’ve helped themselves by porting more Linux commands to work natively in Windows. This move makes it easier for Windows admins and devs to switch to Linux. With the latest horrible moves in the Windows desktop space I can’t believe they’re trying to become the “RedHat of Windows”.

      • enemenemu@lemm.ee
        link
        fedilink
        arrow-up
        1
        ·
        4 days ago

        If your os is windows and use ps, you can use ps on your linux vms as well. It prevents that you have to learn power and bourne. Such that it feels a bit more integrated. If you couldn’t use ps, you had to use both shells which may lead to a migration to linux

    • Possibly linux@lemmy.zip
      link
      fedilink
      English
      arrow-up
      2
      ·
      4 days ago

      They like Linux servers since they make boatloads of money from Azure.

      What they are scared of are Linux desktops and Macs. Windows is losing market share and Microsoft is to big to actual know why.

        • pedz@lemmy.ca
          link
          fedilink
          arrow-up
          1
          ·
          4 days ago

          It became untenable well before that for certain people. It’s all stuff that can be changed or disabled but the Start Menu in Windows 10 with the tiles, and its default search on Bing was infuriating. I do tech support and some clients just don’t bother to deactivate it. There is also the whole thing about Microsoft removing parts of the old Control Panel and its utilities.

          But another aspect of why they may also be losing market is how bad they have been with other architectures, like ARM. Windows for ARM seems to be lacking a lot. Even though they have been slowly getting better with emulation, they are still very much behind macOS and Linux. And I’m just a level 1 tech, but it seems like ARM devices and other low power architectures will slowly replace the old home desktops. They may have made a big mistake there.

          But they still hold the corporate world and governments by the balls so, it’s gonna be interesting to see.

          • applebusch@lemmy.blahaj.zone
            link
            fedilink
            English
            arrow-up
            1
            ·
            4 days ago

            I mean. For me it was the constant forced updates, the adversarial secret config options that may or may not be misdirecting lies that do nothing, constantly forcing edge install, every (forced) update causing worse performance and making the ui shittier, trying to shove one drive down your throat so they can harvest that sweet personal data, forced online accounts, etc.

            • henfredemars@infosec.pub
              link
              fedilink
              English
              arrow-up
              1
              ·
              14 hours ago

              I don’t want to fight my software being actively designed to do what some third party wants it to do. I rather it break for technical reasons rather than political ones.

    • truthfultemporarily@feddit.org
      link
      fedilink
      arrow-up
      7
      ·
      4 days ago

      Can someone explain to me why? The outputs are objects and that is cool for scripts, but the fact that every small thing is its own cmdlet is super annoying. I can do everything in Linux if I know 10 commands. In PS I would always have to look up everything.

      • morbidcactus@lemmy.ca
        link
        fedilink
        arrow-up
        3
        ·
        edit-2
        4 days ago

        If I recall the Verb-Noun idea is supposed to make it clear what is happening, take a look through stuff like the approved verbs for defining cmdlets. There’s aliases and stuff for sure for example I think ls is an aliases for Get-ChildItem in PowerShell.

        It’s supposed to make it so you don’t necessarily need to look things up, need to do something to an item? Well you can Copy, Remove, Rename, Move etc, and while yeah that’s a super basic example that you know the equivalent linux commands for, the concept is supposed to apply everywhere. Now, whether or not people follow the guidelines is probably another story.

        I don’t really hate shell scripting, feel like they all have their place, complex stuff though is nicer in straight PowerShell than bash IMO, but I’m fine using either.

      • bleistift2@sopuli.xyz
        cake
        link
        fedilink
        English
        arrow-up
        3
        ·
        4 days ago

        the fact that every small thing is its own cmdlet is super annoying. I can do everything in Linux if I know 10 commands

        That sounds more like a clash of cultures than a real problem. In Linux you need to know 10 options and possibly subcommands for each command. Naturally the same concept has different flags, and the same flag has different meanings in different commands. Is that really better?

          • jeeva@lemmy.world
            link
            fedilink
            arrow-up
            1
            arrow-down
            1
            ·
            4 days ago

            We’re not talking terminals, though, are we? You can run pwsh in dozens of terminals. As a shell, it’s… Very decent.

          • lazynooblet@lazysoci.al
            link
            fedilink
            English
            arrow-up
            2
            arrow-down
            5
            ·
            4 days ago

            I’ve been a Linux sysadmin for decades and Windows for the year 8 years or so. I started using Windows with an air of contempt, and still do. I hate myself for saying this, but Powershell is better than bash. Bash is very limited if you consider only bash. For bash to be useful you need the entire GNU suite with grep, cut, awk etc.

            • Phoenixz@lemmy.ca
              link
              fedilink
              arrow-up
              9
              ·
              4 days ago

              That’s like saying that your car is very limited because you need cylinders, spark plugs, oil filters…

              Well yeah, you do and typically that comes with the car, just like grep comes with bash

            • porl@lemmy.world
              link
              fedilink
              English
              arrow-up
              7
              ·
              4 days ago

              But that’s almost never how a system is configured. The entire point is that bash, zsh, fish etc. can make use of those utilities. You don’t need bash trying to reinvent everything. You don’t want that. That’s why changing shells is generally painless and a strength, not a weakness.

        • Matriks404@lemmy.world
          link
          fedilink
          arrow-up
          1
          ·
          3 days ago

          What do you mean? If you run powershell directly it opens up either in conhost or Windows Terminal, depending on whatever is your default, doesn’t it? Unless you mean PowerShell ISE or whatever it’s called.

    • brian@programming.dev
      link
      fedilink
      arrow-up
      2
      ·
      4 days ago

      there are other shells that have all the nice powershell things without the weird stuff (at least for not windows people), like nushell

      although I wouldn’t be surprised if powershell was the thing that started the trend of better shells

    • JustEnoughDucks@feddit.nl
      link
      fedilink
      arrow-up
      1
      ·
      4 days ago

      No grep though as far as I could find… There was a similar cmdlet IIRC, but it was extremely limited and didn’t work well (this was years ago though)

      • mcx808@programming.dev
        link
        fedilink
        arrow-up
        1
        ·
        2 days ago
        Select-String
        

        It’s really useful too. You can either pipe in text or for example Get-ChildItem a directory of files and it will parse them all. As usual it returns a helpful object with properties like line number.

        • JustEnoughDucks@feddit.nl
          link
          fedilink
          arrow-up
          1
          ·
          4 days ago

          Fair, but very very very often (unless you are a full time daily user of the commandlet and all objects you may run into or have a photographic memory) you don’t know the actual specific property or object exact verbatim and have to rely on a very quick search to remember that one object you used 3 months ago once that you need now for example. Or you want to see where/if something is referenced in another subset of programs like a specific IP, another program, a resource taken up, etc…

          That is mostly what grep is used for: discovery and reference, which powershell I don’t think has a substitute for so instead you have to sort through documentation and forums.

          • pezhore@infosec.pub
            link
            fedilink
            arrow-up
            1
            ·
            4 days ago

            Not trying to be difficult, but that’s what get-member is for - it’ll dump all the properties for a given object.

            I get it - it’s way different from bash - speaking as someone who has been using Linux since Debian Hamm. Side note, net installers over dialup really sucked.

            I was originally forced to use powershell when I joined up with a virtualization team for work and they used PowerCLI.

            It was bonkers how easy it was to get reproducible scripts bundled up for the more junior engineers.

    • StrawberryPigtails@lemmy.sdf.orgOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      4 days ago

      I’ll take your word for it. I could never wrap my head around PowerShell back when I still had a Windows install. Whenever I could, I would use either the DOS prompt or WSL/Ubuntu. I may not be great at Bash or DOS but at least I’m not having to resort to cargo culting to do anything. Probably a sign I’m getting old.

      • Caveman@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        3 days ago

        I can maybe chime in since I’ve used both. Basic operations like if statements, arithmetic and loops are a lot closer to what you’d expect on PS. The barrier to programming in bash vs PS is IMO a bit higher because bash heavily uses symbols for everything. This does make PS way more verbose but more easy to wrap your head around it when unfamiliar with the syntax.

        I prefer bash but for anything bigger than 5 lines I prefer proper scripting language like python or js and making an alias for “node path/to/js/script.js” and using execSync(“program param1 param2”) to run shell commands.

        Long story short, I prefer bash because it’s built in and I know it better than PS, I expect PS guys to feel the same way.

      • irelephant [he/him]🍭@lemm.ee
        link
        fedilink
        arrow-up
        1
        ·
        4 days ago

        Its a completely different shell, not just another terminal emulator.

        Its more readable, and its syntax is less arcane than bash.

        For example, a script to get the first line of a file and its lenght in bash is:

        #!/bin/bash
        
        
        if [ "$#" -ne 1 ]; then
            echo "Usage: $0 filename"
            exit 1
        fi
        
        filename="$1"
        
        
        if [ ! -r "$filename" ]; then
            echo "File '$filename' does not exist or is not readable."
            exit 1
        fi
        
        
        read -r first_line < "$filename"
        
        
        echo "First line: $first_line"
        
        
        length=${#first_line}
        
        echo "Length of first line: $length"
        

        There is so much I hate about this, like using a semicolon after the if condition, and ending it in fi.

        Versus the powershell version:

        param (
            [Parameter(Mandatory = $true)]
            [string]$FilePath
        )
        
        
        if (-not (Test-Path -Path $FilePath)) {
            Write-Error "File '$FilePath' does not exist."
            exit 1
        }
        
        try {
            
            $firstLine = Get-Content -Path $FilePath -TotalCount 1
        }
        catch {
            Write-Error "Could not read from file '$FilePath'."
            exit 1
        }
        
        
        Write-Output "First line: $firstLine"
        
        
        $lineLength = $firstLine.Length
        Write-Output "Length of first line: $lineLength"
        

        It feels more modern.

        • drspod@lemmy.ml
          link
          fedilink
          arrow-up
          2
          ·
          4 days ago

          bash scripting is not intended to perform all of your logic in the scripting language, it’s intended to call out to other programs which perform specific tasks. The entire POSIX command set is your bash scripting language.

          Your script is a simple one-liner if you know some simple commands:

          $ head -n 1 /usr/share/dict/words | tee /dev/stderr | tr -d '\n' | wc -c
          A
          1
          
          
          • FizzyOrange@programming.dev
            link
            fedilink
            arrow-up
            0
            ·
            4 days ago

            bash scripting is not intended to perform all of your logic in the scripting language

            Maybe not all, but it’s definitely intended to do some, and it’s really bad at it.

            • Possibly linux@lemmy.zip
              link
              fedilink
              English
              arrow-up
              2
              ·
              4 days ago

              It works fine for what it is. Bash is just a shell while Powershell is more of a scripting language.

              I think a better comparison would be Python vs Powershell.

              • FizzyOrange@programming.dev
                link
                fedilink
                arrow-up
                2
                ·
                4 days ago

                It doesn’t work fine for what it is. People use Bash for scripting all the time and it’s full of footguns and gotchas. Powershell is just an attempt at a sane shell. It’s not meant to be a full general purpose language like Python; it doesn’t make sense to equate them.

                Personally I don’t really like the style of Powershell. The structured data is very obviously a good thing but I don’t really like the syntax. Nushell seems a lot nicer IMO.