I’m sure you’ve seen it, PowerShell has been open sourced and is now available on OS X and Linux. Good news is, you can also run PowerShell on macOS Sierra beta in everything I’ve tested so far (I spent more of the day the other day just writing and running Powershell within macOS beta).
Enough about the release, you can go read all about it here – https://azure.microsoft.com/en-us/blog/powershell-is-open-sourced-and-is-available-on-linux/
If you’re on OS X or macOS, here is how you get it running:
- Browse to – https://github.com/PowerShell/PowerShell
- Scroll down the page a little bit and you’ll find the links to both the .pkg download as well as instructions
- Once the .pkg file is downloaded, you can either install it via the command line using:
sudo installer -pkg powershell-6.0.0-alpha.9.pkg -target /
or by opening the .pkg.
If you install by open the .pkg, you’ll need to right click on the file and select open (rather than just double clicking) due to it not being signed and coming from and “unverified developer”.
- Walk through the install process shown in the following screenshots, there is nothing unique about the install, just a typical macOS application install.
Here is a quick video showing the install process using the terminal, running some PowerShell and then modifying Visual Studio Code to make PowerShell my default environment.
Now that it’s installed, we’ll walk through running PowerShell and writing some scripts
- Launch your Terminal, this could be the native Terminal, iTerm, etc.
- Type “PowerShell” and hit Enter, you’ll see PowerShell load and your terminal lines will be prefixed with PS
- That’s it, start running PowerShell cmdlets such as Get-ChildItem
Set PowerShell as the default in Visual Studio Code
If you want to set PowerShell as the default shell in your integrated shell in Visual Studio, just walk through these steps as shown in the video above:
- Code (in the Menu bar) -> Preferences -> User Settings
- Add the line:
- Save the File and Reopen Visual Studio Code. Now when you open the integrated terminal it will be running PowerShell.