PowerShell On Apple Mac OS X


I love PowerShell. Its object-oriented nature is welcome relief from the endless string parsing of bash.

Good news! PowerShell Core installs on Windows, OS X, and Linux. I made it my default in Terminal on OS X. Here’s how.

I tested this on OS X Catalina (10.15) with PowerShell Core 7.

First, install from Homebrew like the docs say:

brew install powershell

Then open Terminal, select Terminal > Preferences in the menu, and set shells to open with /usr/local/bin/pwsh:


Now quit and re-open Terminal. Boom! 💥 You’re standardized on PowerShell.

If you’re like me, though, you also need to add a bunch of stuff to your path. It’s similar to Linux-land, just update an environment variable in your profile, but there were gotchas.

PowerShell exposes an Environment Provider that works like a filesystem drive. That’s where your path is set:

PS /Users/adam> Get-Item Env:PATH
Name                           Value
----                           -----
PATH                           /usr/local/microsoft/powershell/7:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

When I wrote this, the docs gave examples that used both Env:path and Env:Path, but neither worked on OS X. I had to use Env:PATH. It’s tricky because creating the wrong one doesn’t cause errors it just doesn’t do what you want.

The second gotcha was easier. In Windows the separator is ; so that’s what most examples use, but in OS X it’s :. I was copy/pasting from Windows code samples before I noticed the problem.

Just like Linux, modifications to Env:PATH are specific to your session. They’re lost on exit. We can make them permanent. First, find your PowerShell profile:

PS /Users/adam> $PROFILE

Create that path and file if it doesn’t exist. Put this command in the Microsoft.PowerShell_profile.ps1 script:

$Env:PATH += ":/Users/adam/opt/path"

Now quit and re-open Terminal and your path should be up to date:

PS /Users/adam> Get-Item Env:PATH
Name                           Value
----                           -----
PATH                           /usr/local/microsoft/powershell/7:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/adam/opt/path

That’s it!

Happy automating,


Need more than just this article? We’re available to consult.

You might also want to check out these related articles: