- 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.
Installing PowerShell
- 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.
Run PowerShell
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:
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.
Heheh…from personal experience, I can verify this. 🙂 -Tim
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. 😉
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
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.
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
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.
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 😉
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.