Saturday, January 7, 2017

Getting Started with Powershell on Linux

 on  with No comments 
In , ,  
Ever since Microsoft first announced that PowerShell would be released on Linux and Mac, I wanted to grab a copy of it and give it a spin.  Why specifically?  I don't know.  As I explained to someone who asked me that in the Facebook group, I thought because I can was still a valid reason to give anything a try in the Lab.

So armed with a little spare time now that the semester is over and I don't have any classwork hanging over my head, I thought I'd give PowerShell a whirl.  For my first attempt, I downloaded powershell-6.0.0_alpha.9-1 for OpenSUSE.  Working my way through error after error did not lead to any positive result, so I set this project aside for a bit. I chalked this up to the fact that the rpm was built for OpenSUSE 13.2, and I was actually running OpenSUSE Leap 42.1 (the next release after 13.2).

Fast forward a few hours and another member of the group piggy-backed onto my PowerShell post and asked if I had also considered giving SQL Server on Linux a spin. I had not, and actually only very vaguely remembered hearing about this.  So I took this as an opportunity to look at something else for a little bit and step away from PowerShell.  This went much better, and I'll post my thoughts on this product later.

So with that being a success, I decided to take another stab at PowerShell.  This time I downloaded the CentOS/RHEL build, which also happened to be a later release, alpha 14.  I installed this on the system that I had built for SQL Server, and it installed cleanly, and ran cleanly.  This CentOS RPM gives me the same error where I left off on when I installed it on OpenSUSE, so this is clearly a shortcoming of the OS, not the powershell binary.

Failed to initialize CoreCLR, HRESULT: 0x80131500

Most of what I Googled said this goes back to the lack of an environment variable not being set, and I don't remember what the variable is now, but it's dotNET related.  SuSE 6.4 was my first distro, way back in 1999 so there's a strong sentimental attachment there.  But maybe it's time to just move over to CentOS or Fedora.

So what does it look like?  Well, like PowerShell obviously.  It's a command interpreter.  Note the bright colors, you'll need to ensure your terminal has a dark background.

So what is it good for?  That's subject to debate at the moment.  Microsoft envisions this as a means to control Windows systems from a Linux system and vice versa.  Well, unfortunately, that doesn't quite work just yet.  For example, any time you attempt to use Invoke-Command, it results in an error and PowerShell core dumping.

This is known behavior unfortunately.  However, in a separate Git repository, there's a library called PSRP-Server that allows a Linux system to be controlled from a remote Windows system using PowerShell, so hopefully it won't be long until we can go in the other direction.  


Post a Comment

Discuss this post!