Table of Contents
What is a PowerShell on Mac?
PowerShell on Mac is a command-line tool and an associated scripting language that’s developed by Microsoft and primarily used for system management automation. PowerShell on Mac can also be used for building, testing, and deploying solutions, primarily in a CI/CD environment.
The main purpose of PowerShell is to help automate mundane, repetitive tasks that would simply waste time and diminish the efficiency of an Administrator’s workflow. PowerShell allows you to build tools that will help you with your work by performing such repetitive tasks for you, while you focus on more important things. In addition to being a command-line tool, PowerShell is also the scripting language that allows you to build the automation tools you need in your work.
In addition to being available for Windows 7 and later, PowerShell can also be installed and used on Linux and macOS. PowerShell for macOS can be used on both Intel-based and M1 Mac models. PowerShell for Mac is compatible with macOS 10.13 or higher.
How to install PowerShell on macOS
To install PowerShell on macOS, the recommended method is to use Homebrew, as it is the preferred macOS package manager. First, install Homebrew through your Mac’s Terminal, and then use the brew install –cask powershell Terminal command to install PowerShell on macOS.
There are three ways you can install PowerShell – you can directly download it as a .pkg file, you can use Homebrew, and you can also download it from binary archives. Since Homebrew is the recommended macOS package manager, it’s also best if you install PowerShell through Homebrew. The process is easy and involves the use of a couple of Terminal commands:
- Go to Application > Utilities, and open Terminal.
- Copy the following command and paste it into the Terminal’s window:
/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)”
- Press Enter to run the command. You will probably be asked to type in your admin password before the command is executed. Type your password – you won’t see any characters getting written next to password: in the Terminal, but this is because the letters/numbers you are typing are hidden, so don’t mind that and simply type the password anyway. After that, hit Enter again and the command to install Homebrew will be executed.
- After Homebrew is installed, run the next command to install PowerShell (enter your password again if required to):
brew install –cask powershell
- Finally, run the pwsh command to enter PowerShell and to verify that it is working properly.
How do I install PowerShell on Mac?
To install PowerShell on Mac, you can use Homebrew, perform a direct download, or install PowerShell from binary archives. The recommended way to install PowerShell on your Mac is to use the Terminal app to download Homebrew, and then use it again to download PowerShell.
If a new update for PowerShell gets released, you can easily update your PowerShell with it directly from your Terminal. You can use the following commands to do that:
- brew update
- brew upgrade powershell –cask
How do I run PowerShell on Mac?
To run PowerShell on Mac, you can directly download its .pkg file from Microsoft’s site, or you can use Homebrew to install PowerShell. Once PowerShell is installed, you can run it by opening a Terminal window and executing the pwsh command.
Once you’ve installed PowerShell on your Mac, you can start it at any time with the pwsh command. After you execute the command in your Terminal, you can start using the PowerShell script to build automation tools for your work.