- Poll: How reliable are ChatGPT and Bing Chat? - Tue, May 23 2023
- Pip install Boto3 - Thu, Mar 24 2022
- Install Boto3 (AWS SDK for Python) in Visual Studio Code (VS Code) on Windows - Wed, Feb 23 2022
However, the current Alpha release lacks many features. I will cover a few of the problems I encountered below.
- First, download the PKG package and double-click the PKG file.
- If you are working with default security settings, you can only install apps from the Mac App Store. Even if you allow identified developers, you will receive this error message: "powershell-6.0.0-alpha.9" can't be opened because it is from an unidentified developer.
To resolve this, click the Apple symbol in the menu bar and open System Preferences > Security & Privacy and then click Open Anyway.
- The PowerShell installation wizard will then guide you through the installation. I don't recommend changing the default installation folder.
After PowerShell is installed, you can start it in a Mac Terminal by executing powershell.
The $PSVersionTable variable allows you to display the PowerShell version. Interestingly, we are running PowerShell 6.0. I suppose that means that we will also see a new PowerShell version for Windows 10.
The default paths are a bit different than they are under Windows:
$PSHOME is /usr/microsoft/powershell/6.0.0-alpha.9/ User profiles: ~/.config/powershell/profile.ps1 Default profiles: $PSHOME/profile.ps1 User modules: ~/.local/share/powershell/Modules Shared modules: /usr/local/share/powershell/Modules Default modules: $PSHOME/Modules PSReadLine history: ~/.local/share/powershell/PSReadLine/ConsoleHost_history.txt
For instance, you can store your PowerShell profile in profile.ps1 in your home directory in /.config/powershell/. Note that your Mac Terminal profile will be loaded as well. So for instance, the environment variables you set in your Mac profile will automatically be available in your PowerShell session.
What is working, and what is not
My first impression was that PowerShell on the Mac looks and feels like it does on Windows. For instance, PSReadline works as expected. The syntax highlighting colors are the same as on Windows. You can backward and forward search in the command history (CTRL-R, CTRL-S), and command completion works as well.
However, after I played a while, I encountered a couple of things that didn't work as expected. Of course, this is partly because we are running an Alpha version.
The first thing that caught my eye was that the execution policy is set to unrestricted. I was a bit surprised that I received an Operation is not supported on this platform message when I then tried to change this configuration with Set-ExecutionPolicy.
After this experience, I expected that important PowerShell modules probably wouldn't work in this release. The first module I tried was to install was Azure:
As you can see in the screenshot, my attempt failed when I executed Install-Module: Unable to find module providers…
Considering that the Azure module is installed via an MSI and depends on binaries, it will probably take a while for this module to be available on the Mac.
So I tried a simpler module. I manually downloaded Get-FreeDiskSpace and copied the extracted files to ~/.local/share/powershell/Modules. Automatic module import worked. However, the Get-FreeDiskSpace cmdlet threw an error:
I would love it if Get-FreeDiskSpace is right and all my disks have more than 100% space available. Apple hardware is great but not that great. Thus, I am afraid the relatively simple module couldn't deal with the disks on my Mac.
I think this is a general problem for PowerShell on platforms other than Windows. A shell and a scripting language have to be tightly integrated into the operating system.
Nevertheless, to end the article with a sense of achievement, I can report that the core PowerShell cmdlets work:
PowerShell for the Mac is currently not ready for prime time. You can play a little with the core cmdlets, but that's it. Of course, this early release also contains bugs. For instance, if you resize the Terminal window, the cursor jumps to somewhere in the middle of the window.
The final release will probably offer more features, and I hope Microsoft will include important modules like AzureRM. However, I doubt that PowerShell for third-party platforms will be able to replace a PowerShell console on Windows any time soon.
Subscribe to 4sysops newsletter!
The fact that Microsoft open-sourced PowerShell will certainly help here. It will be interesting to see how quickly the community can adapt the popular Windows shell for Mac and Linux so that it can seriously compete with bash and other popular shells on these platforms.