PowerShell On Linux! Really?

What better way to endure a long conference call, than to dump the latest version of Fedora (26) onto an old laptop?  I’m not really sure why I did this, given that the last time I even looked at Fedora the release version was a single digit.  Yet, there was some joy in watching the old ASUS boot a GNOME interface, which upon login wasn’t even remotely familiar.

Pas de probleme, given that the majority of hours dedicated to Linux has been in BASH.  After some random hovering and clicking in the GUI, the Terminal blinked a warm, welcoming beacon.  Ahhhh, now this feels more like it.  Except … it doesn’t.  A turn in the career path a few years back reduced Linux responsibilities while increasing VMware and Microsoft duties.  Yes, a throwback to a quarter century ago, when I first stared at a MSDOS 4.0 C:\>.  Nostalgia….

Then, a flash of ingenuity!  Perusing a website some months ago, didn’t I read that PowerShell and .NET actually run on Linux?!?!  Those few times at work when I login to a Linux Box, don’t I catch myself using sl, gc, select, where?  Wouldn’t it be cool to try out this Open-Source-Microsoft-Linux-Twist?  You betcha!

Certainly this would require tweaking a makefile, compiling source code, and some form of witchcraft to pull off.  But hey, it’s almost Halloween, right?  Pourquoi pas?!  Allons-y mes amis!

About five minutes later, gci  | ? length –gt 1000 | select basename , extension returned a familiar, correct object from the Fedora ASUS Laptop.  [math]::Round(4.7763,2) gave me the expected 4.78.  Let’s try something Linuxy from PowerShell:  grep root /etc/passwd – all good.  systemctl status – yep, just the way it should be.  Si facile.

And the irony:  I made the whole thing more complicated than it had to be by first installing the DotNet package, then installing the PowerShell package.  When I subsequently performed this on a RedHat Enterprise Linux Server, only the PowerShell package was necessary.  Likely that’s all that would have been necessary for the Fedora Laptop as well.  Just an RPM – no requisite incantations or compiling.

The only hurdle encountered was invoking the shell after installation.  I assumed typing powershell would work.  Nope.  pshell?  No Joy.  OK, cat /etc/shells.  Ahhhh, there it was pwsh, the magic four characters.  /usr/bin/pwsh if you feel like typing the whole thing.

PowerShell, quite the complement for CLI Administration on Linux.  I’ve already employed its functionality for file-related tasks.  How will you wield this tool?