Powershell is a popular shell interface and command line tool. Since it’s a Microsoft tool, you might not think of it as one you can use on your Mac, but you can. Powershell is a cross-platform tool available for Windows, macOS, and Linux.
Powershell can be installed on your Mac using Homebrew and once installed you can easily run it using Mac Terminal.
My name is Eric and as a software engineer for over 25 years, I have used a variety of command shells and command line tools. Powershell is a versatile tool that can be used on different platforms and I can show you how to use it on your Mac.
Keep reading below if you would like to see how to install and run Powershell on a Mac. The steps are straightforward and you can have Powershell up and running in just a few minutes.
Contents
Install Homebrew
The easiest way to install Powershell is to use Homebrew because it will download all the files you need and set everything up for you automatically. If you don’t already have Homebrew installed on your system, I will show you how to install it first. If you have it installed you can move on to the next section.
If you are unsure if you have Homebrew installed you can do a quick check to find out. Open a Mac Terminal session and type the following command.
brew info
If you have it installed you will get a message similar to the one shown below.
If you don’t have it installed you will see a message saying that the command was not found. You can install Homebrew with the command shown below.
/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)”
You’ll be asked for your admin account password. This should be the password you use to log in to your Mac. Then, you will see lots of output on the screen.
Keep an eye on the screen as you may need to hit Return/Enter to continue and possibly enter your password again. The entire installation will take a few minutes. Once Homebrew has installs you will now be ready to install Powershell.
Install Powershell
If you already have Homebrew installed or just installed it using the command above, you are now ready to install Powershell. Installing Powershell using Homebrew is quite easy. All you need to do is open a Mac Terminal session or use the one you opened in the step above.
In your Mac Terminal window, type the following brew command to install Powershell.
brew install –cask powershell
The brew install command will download and install all the required files and set everything up for you. It will ask you to enter your admin password during the installation. This will again be the password you use to log in to your computer. Enter it and hit the return key.
Once the installation finishes, you will see a message stating that Powershell was successfully installed!
Test Powershell
Once you have run the brew command above to install Powershell and the installation has completed, you will want to test Powershell to ensure it is working. Testing it is simple, just run the Powershell command (pwsh) as shown below.
pwsh
If Powershell is working, you will see a message showing the current Powershell version and you will then see the Powershell prompt (PS />) as shown in the image above. You are now ready to run Powershell commands or Powershell scripts!
Once you have tested Powershell and have been using it for a while, you might wonder how to get out of it. Getting out of Powershell and back to your Mac Terminal’s default shell (usually z shell or zsh) all you need to do is type the exit command as shown below.
exit
Basic Powershell Commands
Remember that Powershell is a Microsoft product, so the commands that you use in Powershell are very similar, if not the same, as those in a Microsoft Windows command line environment.
In fact, they are the exact same as what you would use in Powershell on a Windows or Linux machine because Powershell is a multiplatform tool that has been developed for all three systems.
Powershell uses commands like dir, chdir, del, copy, and more. It also has some of the same commands you are familiar with in your default Mac Terminal shell. If you are not familiar with Powershell commands or this is your first time using them, Microsoft has a list of some of the most commonly used commands.
After using it for a while, you will find that it is a useful, fairly easy-to-use tool. I use it almost daily in my work and I have found it to be a very powerful tool for many different applications.
FAQs
Below are a few frequently asked questions about Powershell and how to install it on a Mac system.
Are there other ways to install Powershell on my Mac?
Yes, there are other ways you can install Powershell on a Mac, such as doing a direct download from GitHub. I recommend sticking with the Homebrew method because it is simpler and gets everything set up properly for you. Microsoft does have information on how to install via direct download if you wish to do so.
Is there a GUI interface that I can use to write and run Powershell scripts?
Yes, there are GUI interfaces that you can download that will allow you to write, develop and run Powershell scripts. If you are serious about doing this, I recommend using VS Code. It is free, easy to use, and made by Microsoft so you can easily set it up to work with Powershell. In fact, you can write scripts in the interface and run/test them right there without ever needing to leave the VS Code application.
Writing and running a simple Powershell script in VS Code
Is there a way to uninstall Powershell?
If you find that you don’t like Powershell or just want or need to remove it for whatever reason it is very simple to do. It is as simple as installing it. Just run the brew uninstall command as shown below.
brew uninstall –cask powershell
Conclusion
Powershell is a nice, easy-to-use, powerful scripting tool. Although it is made by Microsoft, you can install and run it on your Mac computer. Installation is simple using Homebrew and you can have it up and running in a matter of minutes.
I hope that the information above has helped you to get Powershell set up and running on your Mac. As usual, let me know if you have any comments or questions. I would love to have your feedback.