powershell on macos

I wrote in an earlier post about easily installing multiple applications on macOS. One of those applications interestingly enough is Microsoft’s PowerShell. Microsoft has open sourced PowerShell and made it available on GitHub (https://github.com/PowerShell/PowerShell). From GitHub you can either grab the source and build it yourself, download and install a pre-built binary, or both. I chose to just grab the binary and run with it as I have enough projects to keep me occupied as it is. The current PSVersion is 6.0.0-beta, and it’s shown running on macOS 10.12.5.

I start PowerShell for Mac from the ITerm2 command line, and from there I can look about PowerShell all I want. While the shell appears feature complete as far as syntax is concerned, PowerShell for Mac is missing considerable core .Net functionality when compared to the versions that run on Windows. As one small example shows below, Get-PSProvider doesn’t show the provider for the registry, as there is no equivalent (at all) on macOS. While it’s nice to have the same shell running across multiple platforms, as bash does, PowerShell for Mac and Linux isn’t going to be nearly as useful as it is on Windows if you want full Windows functionality on another OS. Any PowerShell scripts that are developed to take heavy advantage of Windows OS functionality are going to fail pretty hard on both the Mac and Linux, just to give you fair warning.

By the way, two comments on PowerShell help:

  1. If you decide to update PowerShell’s help, then run PowerShell as sudo before running Update-Help, or the updates will fail.
  2. The graphical view of help (via -ShowWindow) isn’t implemented and won’t work.

One tool not provided by the PowerShell project is the PowerShell ISE (Integrated Scripting Environment). The ISE is bundled with every copy of Windows these days, and is a powerful way to write and debug PowerShell scripts of any complexity on Windows. For the Mac the next best tool to use is Visual Studio Code with the PowerShell v1.4.1 extension (see below). You get full syntax highlighting and support as well as a split screen with code at the top and a PowerShell prompt at the bottom. The only major feature missing in this setup is the help section that is displayed to the right (by default) in the native ISE.

PowerShell for Mac and Visual Studio Code for Mac are an interesting counterpoint to Windows Subsystem for Linux on Windows 10. For those folk who like to “swim” in the lower regions of coding and operating systems, we’re living in a golden era.

my opinion on macos

In the last post about iOS, reader Wolfgang Lonien asked:

Would be interesting to hear your opinions about MacOS vs. Linux and BSD. How much of it is open like in BSD, how much is the proverbial “walled garden”?

The answer is complicated, and I’ll answer it in two parts.

Open vs Closed

The commercial version is closed. It’s not open like Linux or BSD. macOS as it’s now known (and was known as Mac OS X in previous incarnations) is closed, along with the many support frameworks and applications that come bundled with it. It’s shipped pre-installed on every Mac that Apple sells, ready to run as soon as the new Mac is powered up. This simplifies things greatly. The problem with this pat answer is that while the official binary version as shipped is closed, Apple has released the source code in a limited form for an open version known as Darwin.

Darwin is the source to an operating system composed from NeXTSTEP (later OPENSTEP), elements from BSD, and the Mach microkernel. NeXTSTEP was the underlying OS for Steve Job’s NeXT computer, the computer he developed when he left Apple in 1987. When Steve was re-hired by Apple in 1997, one of the stipulations placed upon Apple upon re-hiring Steve was that Apple would buy NeXT. Apple then announced that the next official Apple OS for the Mac would be derived from NeXTSTEP/OPENSTEP. It was finally released as a public beta in 2000 as Mac OS X. At the same time in 2000, the core elements were released as open source as Darwin under the Apple Public Source License. The Cocoa and Carbon frameworks in particular, as well as many higher-level tools, remained closed.

Here’s what uname -v shows in ITerm2:

Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64

In the first ten years of Darwin, up to 2010 and Darwin 8.0.1, Apple released a binary ISO to help install Darwin. After 2010 it has only been released as source code. Apple has never released the iOS variant for ARM.

I’m sure this sounds terrible to the purists, but I personally don’t care. The OS works, it’s solid, and I love the desktop. After over 30 years working with graphical desktop operating systems from Windows 1 through AT&T System 3, IRIX, UnixWare, Solaris, and on through Windows 10, I find macOS to be the most refined of them all. It’s notable that macOS is the first, and only, BSD variant I work with. I’ve tried many times in the past to install Free BSD and Net BSD on hardware and virtual machines, and I’ve given up every time due to one stupid glitch after another with the installation. I have no love for any other BSD except Apple’s macOS.

Walled Garden vs Open Installation

Apple’s macOS has its own App Store where you can purchase thousands of applications. It’s not ideal, and many have complained against it since its introduction in 2011. My biggest complaint is that I can’t update apps purchased outside of the app store within the app store. Biggest example of this is my purchase of OmniGraffle. While the App Store shows I have it installed, I have to go to the Omni Group’s website to pick up (and pay for) major upgrades. Free minor updates come via the application itself. It’s an annoyance, to be sure, but it points to a key positive point: You can install any software you want without having to use the App Store.

I have, for example, HomeBrew, through which I have the latest releases of gcc, python, and R; Google’s Go language, Mozilla Research’s Rust, Oracle Java (version 8 update 131 for now), NetBeans 8.2, JetBrains Toolbox with four of their IDEs, Xcode, Visual Studio Code, Android Studio, PowerShell for macOS, Sublime Text, Iterm2 (because I absolutely cannot stand Terminal), VirtualBox (with several Linux VMs), Office 365, GitHub’s desktop, Unity, Blender, Lightroom, and on and on and on. In short the system is wide open to serious development tools and just about anything that can be installed and/or compiled to work on macOS.

As for the App Store, it’s good about delivering updates/upgrades to macOS and all the Apple tools that came pre-installed. The only thing I’ve installed from the App Store are “minor” applications like Bear (in fact I think that’s the only thing I’ve installed from the macOS App Store). macOS isn’t locked down the way iOS is, and I appreciate that, the same way I appreciate that iOS is as locked down as it is. My iPhone has become a vital part of my personal and work life, and if it wasn’t as locked down as it is now, I’d lock it down hard myself. It’s one of many reasons I switched from Android (Samsung Galaxy) to an iPhone back in 2015. Android is far more easily hackable and rootable than iOS; way too easy.

One More Thing

macOS is UNIX Certified, specifically The Open Group UNIX® 03 standard. I tend to pay attention to standards in my line of work, and the fact that macOS conforms to the UNIX standard, instead of calling itself UNIX-like, adds to the value of the overall computer system I use for my personal and professional work. Neither Linux nor the free BSDs are there, and probably never will be. That doesn’t mean I won’t use them, but then again, it also means I won’t walk away from macOS nor the hardware on which it runs. I depend on all my tools, and I want them to be the best quality tools I can possibly afford. macOS definitely fits in the quality tool category.