Archives For Powershell

powershell on macos

July 4, 2017

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 ( 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.

Visual Studio Code in PowerShell Git Repository

Visual Studio Code in PowerShell Git Repository

While taking breaks during the day (and later this evening) I pulled the PowerShell source from Github. I got it to build, after a fashion, but the build process wants to run a series of tests, and the tests are failing a bit. Considering this is alpha code, I’m not that concerned, and consider this to be a learning opportunity.

I will clarify this about the build directions on OS X;

  1. install a PowerShell pre-built binary as Microsoft recommends and start that up;
  2. go down into the PowerShell top Git directory (in my case it was ~/Git/PowerShell);
  3. execute ‘Import-Module ./build.psm1’ within PowerShell.

That will define the PowerShell function Start-PSBootstrap that you need to execute in order to set up the PowerShell build environment. That little detail about sourcing build.psm1 is missing in the OS X directions, although it’s there in the Linux directions. Good thing I read around a bit…

GitHub Desktop with PowerShell Repository

GitHub Desktop with PowerShell Repository

I am pleased with the tools I have installed on the MBP. Visual Studio Code seems to be a rather decent editor (and debugger with the right extensions installed). I’m using it so far for Rust, Go and Python, and tonight I got it set up for C# editing. It comes with the ability to navigate a local Git repository copy out-of-the-box. All on a MBP under Mac OS X 10.11.6. I’m also pleased with GitHub Desktop. I can browse the repository metadata and the diff tool is again pretty decent. My only problem is I couldn’t use the Desktop to do the pull; I had to use the command line tool. I’m no git expert, and my understanding of the Desktop is even more limited. But again, it’s an opportunity to learn.

I’m something of a tool packrat, having installed a fair number of editors and IDEs over the years. For example I’ve purchased a license for Sublime Text, I’ve got Komodo Edit 9 installed, and I even have a copy of Atom installed. About the only editor I don’t have on OS X is Notepad++ (unfortunately, only available on Windows), an editor I use on Windows when I need to get serious about text and code editing without the bloat of a full-up IDE.

So, new tools, new code, a new(ish) shell to spark some interest. I’m looking for a full-up replacement for Java, so maybe I need to give C# another look. PowerShell is written in C#, so there’s that. I know that the cool kids look askance at C#, and I know that Java is still considered the #1 language for making a living. But Oracle has made using Java hellish, and I have no desire to use the language any more. C++, C#, Python, Rust, Go, Javascript; there are so many other good alternatives and what I listed doesn’t scratch the surface of computer languages. It’s such a rich development environment these days.

powershell on a mac

August 19, 2016
Powershell on a Mac

Powershell on a Mac

tl;dr – Microsoft open sourced Powershell. Source, installable packages, and instructions for installing it or building the repository are on Github.

In case you missed it, Microsoft has open sourced its Powershell “super” shell. Right now it’s an alpha release, with all that that implies. And for those who care about such things, it’s released with the MIT open source license, not GNU. You can either grab the sources via git and built it yourself or you can download pre-built installation binaries. I chose to the pre-built Mac installation package to quickly get something up and running. I don’t have a lot to add to the conversation at this point as I’m certainly no Powershell guru. But from what little I do know about Powershell, it all appears to work on my Mac. In the example shown here I’m running Powershell in iTerm2, a better alternative to Apple’s Terminal. Perhaps future releases will be able to create a shell without this intermediate step; it would be nice.

Since upgrading to Windows 10 it’s a tiny bit ironic that I’ve been spending a lot more time in Powershell than I have in prior versions of Windows. What probably pushed me towards Powershell was my eventual dissatisfaction with the Windows Linux Subsystem and its inclusion of bash. I am not a bash fan, and find little to like with any of the other Unix-like shells (csh, tcsh, ksh, zsh, etc, etc). I’ve used all those other shells because that’s all you’ve got. I haven’t gotten excited about a shell since my days of using 4Dos on MSDOS and OS/2. I personally would like a common powerful shell environment across all my various operating systems, but somehow bash and its ilk are not it for me. Since source and instructions for building the repository are available, I’m toying with the idea of building Powershell on Arch Linux ARM for the Raspberry Pi. More to come on that, perhaps…