PowerShell on Linux and Mac OS X: Kumbayah or Microsoft Takeover?

Microsoft has really turned over a new leaf in regards to its view of the previously despised Linux operating systems. Satya Nadella has led the company through a complete 180. Not only have they stopped dissing Linux, Microsoft seemingly fully supports it. Previous CEO Steve Balmer tried to put Linux in a guillotine with its 59,000 strong, patent portfolio blade. He pushed companies into signing patent licensing deals; search Amdocs for the details on one such agreement.

With Nadella at the helm, the company now views Linux as an asset rather than a competitor. They may be on to something, Linux is a fantastic operating system that has propagated to data centers world-wide. It usually far outnumbers Windows nodes in those same dcs. However, a lot of the software available for Linux is sub-par in many a users’ eye. Kolab is able to ape some of the best features of Microsoft Exchange, but lacks the polish and scalability features. Libre Office Writer 5 is good for free software, but I write all my documents in Microsoft Word.

The ablity to run Microsoft’s flagship software on Linux machines could greatly expand Microsoft’s user base, both in the Enterprise and by individuals. Last year MS released an edition of its SQL 2016 Server that runs on Linux and enabled Bash (the Linux terminal for my Windows readers) in Windows 10. It fully supports Linux virtual machines in its Azure cloud and Unbuntu on Windows is available in the Microsoft store.  Its latest offering is the ubiquitous PowerShell and .Net core. The old lines in the sand are starting to become awfully blurry. The official Microsoft announcement is here if you’d like to read it.

Speculation could lead one to ponder what else will run on Linux now that it has the next-gen .Net framework easily available. Rumors abound that everything from Microsoft Exchange to Microsoft Office is on the way. Only the future will tell for sure, but I can’t imagine that MS went to all this trouble just to let Windows admins run their PowerShell scripts on the Linux team’s VMs. Python isn’t that big of a leap for those of us that are proficient at PowerShell, there’d be no reason for this type of overture unless they have plans to do something more with it.

So how do we get PowerShell on to Linux and what can you do with it after you do? Let’s find out! If you don’t have an old system lying around that you can toss your favorite Linux distro on, I suggest building a VM on your Windows machine. You can use Hyper-V if you have Windows 10 Pro or Server, and VirtualBox if you don’t. See my article about building a VM on windows for more info.

I’m using Ubuntu 17.10 and I’m going to add the Microsoft repository to my package manager so that my install stays up to date with my regular update procedure. If you’re doing this on a MAC you’ll want to grab one of the OS X packages from the GitHub Repository. The Macintosh operating system has an unknown developer lock on it just like your phone does. You’ll need to CTRL + Click on the PKG file that you downloaded and then pick Open to bypass the security feature. Follow the Wizard to complete the installation.

In Ubuntu, open a terminal and follow the instructions below.

  1. We need to add the curl program unless you’ve already had to for some other task.
    1. Type: sudo apt install curl and press enter.
  2. Now we’re going to import the repository GPG keys.
    1. Type: curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add – then press enter.
  3. We need to register the repository.
    1. Type:  curl https://packages.microsoft.com/config/ubuntu/17.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list and press enter.
  4. Next we need to check for updates.
    1. Type: Sudo apt-get update and press enter.
    2. installpowershellonlinux2
  5. All that’s left is to install PowerShell
    1. Type: sudo apt-get install -y powershell

That’s it, you’ve installed PowerShell on Linux. To those of us that have been in tech for more than a few years, that is a very odd sentence to type. Now what? Well, first you’ll need to launch it. Open your terminal and depending on the version of Linux/Mac OS X and the package you’ll need to type either powershell or pwsh to access it.

Once you’re in, it works exactly like it does on Windows. A good way to see what you can do is to list out the commands and modules available. Try Get-Help Get* for a list of get commands and Get-Help Set* for the settings you can alter. Get-Module -list is also handy.linuxpowershellget

There are a lot of commands available but some of my favorites are missing. Get-NetAdapterConfiguration and Test-Connection are nowhere to be seen but the trusty Get-ChildItem and Get-Process are both fully functional. You’ll have to check for your favorites. One would assume cmdlets will be added with future updates as there were in the evolution of PowerShell on Windows.

As I’ve stated in numerous posts before, I like and use all technology. I see the new trend of intergration as an extreme advantage for the future of computing in general. I sincerely hope it continues.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s