In my previous post, I explained how to install PowerShell on Ubuntu. It is quite simple to do so on both Ubuntu 16.04 and Mac OS X.
Latest posts by Michael Pietroforte (see all)

However, the current Alpha release lacks many features. I will cover a few of the problems I encountered below.

Installing PowerShell

  1. First, download the PKG package and double-click the PKG file.
  2. 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.
    PowerShell package can't be opened

    PowerShell package can't be opened

    To resolve this, click the Apple symbol in the menu bar and open System Preferences > Security & Privacy and then click Open Anyway.

    Open Anyway in Security and & Privacy

    Open Anyway in Security and & Privacy

  3. The PowerShell installation wizard will then guide you through the installation. I don't recommend changing the default installation folder.

    PowerShell installation wizard

    PowerShell installation wizard

Run PowerShell

After PowerShell is installed, you can start it in a Mac Terminal by executing powershell.

Start PowerShell

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

PSRreadline backward search

PSRreadline backward search

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.

Execution policy is set to unrestricted

Execution policy is set to unrestricted

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:

Install-Module not working

Install-Module not working

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:

Get-FreeDiskSpace module not working on Mac OS X

Get-FreeDiskSpace module not working on Mac OS X

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:

Get-ChildItem on PowerShell for Mac OS X

Get-ChildItem on PowerShell for Mac OS X

Conclusion

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.

8 Comments
  1. Apple hardware is great but not that great.

    Heheh…from personal experience, I can verify this. 🙂 -Tim

    • Author

      Yeah, it is a pity because the 1TB SSD on my MacBook is almost full. Too bad that Steve Jobs is no longer around. I guess he would hire the Get-FreeDiskSpace developer right away and integrate him in Apple’s realty distortion team. If only this could solve my storage problem. 😉

  2. Milan 7 years ago

    What would be the use case for PowerShell on Mac in the future? You mentioned that “A shell and a scripting language have to be tightly integrated into the operating system.”, so what will most probably happen?

    Will Powershell in such cases be used to manage only Windows based remote machines from another OS? How will open-sourcing .Net framework influence this? Your thoughts on the direction of this new developments and MS open-sourcing their products would be appreciated.

    BTW powershell v6 alpha is available for Windows 10  on GitHub: https://github.com/PowerShell/PowerShell

     

    • Author

      Milan, I believe the open source community will add the features that PowerShell needs to compete with other shells and scripting languages. I think this is the main reason why Microsoft open sourced PowerShell. Without this move PowerShell’s future on Linux and OS X would be rather grim. PowerShell is well-designed and extremely popular. Thus, I even think that is possible that PowerShell will become THE scripting language in the long run.

      However, in the beginning PowerShell will mostly be used to remotely manage Windows and Azure. I just hope that it won’t take Microsoft too long to port the corresponding modules.

      As to .NET, thus far I didn’t see reasons to use it on other platform than Windows. Maybe PowerShell will change this.

  3. I would add that because Linux and macOS both have a Common Information Model (CIM) repository just like Windows does, the plan is for us sysadmins to use PowerShell Desired State Configuration (DSC) to configure Linux and Mac servers.

    All this open source/cross-platform stuff is in Microsoft’s best interests. First of all, they make it easier for Mac and Linux users to “mix it up” with Microsoft products and technologies. Second, they get free development help and tech support by allowing community contributions in their GitHub repositories.

    Lastly, Azure’s support of Linux opens up pools of new prospective customers that Microsoft would have otherwise lost to Amazon or Google.

    T

    • Author

      I agree Azure’s support for Linux is essential for Microsoft. If we really will be able to manage Linux via DSC, then Azure has a significant competitive advantage over AWS. Even if Amazon supports DSC, many organizations will prefer the cloud of the PowerShell maker because it might simplify support cases. I believe PowerShell is Microsoft’s trump card against other cloud providers.

  4. Milan 7 years ago

    Michael and Tim, thanks for your comments.

    These are exciting times currently, with Editor Services, VS Code editor and similar efforts from MS.
    It will be interesting to see if they accomplish the goal of getting more non-Windows VMs into Azure that can all be managed by PowerShell, or maybe even making a bigger impact on other OSs.

    It is sometimes funny to see how Jeffrey Snover is involved into community discussions and defending PowerShell in front of very hostile Linux crowd. Anyway, I like this new MS attitude as long as it makes our skills more usable and attractive in the job market 😉

    • Author

      I can imagine that many Linux admins are hostile to PowerShell. I’ve been working with many different programming languages in the last 30 years or so and I’d say that UNIX/Linux scripting languages have the most cryptic syntax. Most Linux admins love this because it makes them feel geekier. PowerShell, on the other hand, is very easy to learn. Imagine a Perl scripter who is supposed to code in PowerShell. It is like telling a PowerShell geek to work with a GUI tool.

      It also means that Linux admins will face competition from a myriad of Windows admins who have been working with PowerShell on Windows. In a way, Microsoft has been simplifying scripting in the last few years in the same way has they once simplified system administration with the GUI.

      Nevertheless, I think it is possible that many Linux admins will move to PowerShell once the open source community added the currently missing features. In the end, what counts is how fast you can get the job done and not how geeky you are.

Leave a reply

Your email address will not be published. Required fields are marked *

*

© 4sysops 2006 - 2023

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account