How to Install PowerShell for Mac: Easy Step-By-Step

PowerShell for Mac
Image by rawpixel.com on Freepik

PowerShell is a powerful programming language, and scripting implies the ability to automate tasks. However, installing PowerShell on a Mac can be difficult. But don’t be concerned. After following this guide, you will be able to use PowerShell on your Mac in the same way that you would on a Windows machine. Keep reading to learn how to install and run PowerShell Core on a Mac. The process is simple, and you can get PowerShell up and running in a matter of minutes.

What is PowerShell for Mac: Overview

Microsoft created PowerShell, a command-line tool and scripting language that works with it on Mac. Its main purpose is to automate system control. You can also build, test, and release solutions with PowerShell on a Mac, mostly in a CI/CD environment.

PowerShell’s main goal is to help automate boring, repetitive jobs that would otherwise take too much time and slow down an administrator’s work. Because PowerShell lets you make tools, you can automatically make them do boring jobs while you work on more important things. In addition to that, PowerShell is both a command-line tool and a programming language that you can use to make the automation tools you need for your job.

How to Install PowerShell for Mac

To install PowerShell on macOS, the best way is to use Homebrew, which is the chosen package manager for macOS. In the Terminal on your Mac, first install Homebrew. Then, to install PowerShell on macOS, use the command brew install -cask powershell.

Also, downloading PowerShell as a.pkg file, using Homebrew, or downloading it from a binary package are the three ways to install it. This is because Homebrew is the best package manager for macOS, so that’s how you should install PowerShell too.

How to Install PowerShell for Mac: Step-by-Step Guide

Homebrew is the package manager for Mac that works like apt for Ubuntu or Yum for Fedora. When you install apps on a Mac, it is more practical to do it this way than directly. In other words, Homebrew lets you install the latest stable or preview version of PowerShell for Mac on your computer by following a few steps. Follow these detailed steps to successfully install PowerShell on your Mac:

#1. Installing PowerShell For Mac

A safe version of a program means that it has been tested a lot and is now ready to be used in the real world. To use Homebrew to install PowerShell on a Mac, do these things:

  • Start up the Terminal app.
  • Run the following PowerShell installation code: The “brew” part is the main Homebrew command, while the “cask” part is an add-on that lets Homebrew install macOS apps.
  • Install the cask powershell with brew
  • A result like the one below will be displayed when the installation is finished. At this point, PowerShell 7.2.6 is the most up-to-date fixed version.
  • Lastly, run the code below to start PowerShell.

pwsh

  • You’ll see something like a picture, which means PowerShell is running on your Mac.

#2. Installation of PowerShell on a Mac

Microsoft also gives away preview versions of PowerShell. The new features in these updates haven’t been properly tried yet, so they shouldn’t be used in production. You might want to install a preview version on your computer to try out the new features. A preview version of PowerShell for Mac can be installed by following the steps below.

  • Run the command below to add the repository for Homebrew versions. The preview versions of PowerShell and other apps can be found in this repository.
  • Tap brew and cask versions 
  • Execute the PowerShell command below to install the latest PowerShell Preview version.
  • Install-cask PowerShell-preview with brew
  • A result like the one below will be displayed when the installation is finished. At the time this was written, 7.3-preview 7 was the latest version of PowerShell Preview.

#3. Upgrading PowerShell for Mac

Using Homebrew, you can upgrade PowerShell for Mac to the most current version. New versions often include fixes for bugs and improvements to how well they work.

To update PowerShell for Mac to the most current stable version, run the lines listed below in your terminal. The first command changes the list of Homebrew packages. With the second and third commands, PowerShell for Mac is updated to the most current stable and preview versions.

  • Update on the Brew
  • Upgrade to brew Use PowerShell-Cask
  • Upgrade to brew With PowerShell-Preview-Cask.

#4. Installing PowerShell For Mac Using PKG Files

Microsoft also gives you PowerShell for Mac PKG installer files. The PowerShell GitHub updates page is where you can get these files.

  • On your macOS device, download the PKG file powershell-7.2.2-osx-x64.pkg.
  • After you double-click the file, the installation will begin.
  • Get OpenSSL set up. OpenSSL is needed for PowerShell remote access and CIM tasks.

But the PKG installer is for you if you’d rather use a GUI to install software than the command line. Follow these steps to use a PKG file to install PowerShell:

  • After starting your browser, go to the PowerShell GitHub current releases page and click on the drop-down menu next to Assets.
  • Click on the link for the PowerShell PKG file that matches the type of CPU in your machine. In case your Mac has an M1 chip, pick the arm64 choice. If not, pick the x64 link.
  • Save the file in the Downloads folder.
  • If you double-click the saved file, the installer will begin. Then, choose “Open.”
  • Click Continue on the Introduction screen.
  • When using PowerShell for Mac to install something, only the current user account is allowed. It is not possible to choose a unique installation target path.
  • Click Install on the O on the Installation Type screen.
  • Click Close on the Summary screen to finish the installation.
  • Type in “PowerShell” to run PowerShell from the Launchpad. Then, select PowerShell from the results to launch it.

#5.  Installing PowerShell For Mac Using Dot Net Developer CLI

The easiest way to install PowerShell on Mac is to use the Dot Net Developer CLI. There is a DOTNET command-line interface (CLI) called the Dot Net Developer CLI that works on multiple platforms and lets you make, build, run, and share programs.

  • If you are a developer and already have dotnet CLI set up on your Mac, this might be the easiest way to install PowerShell.
  • Use the command below to install PowerShell through the dotnet CLI.

DOTNET TOOL INSTALL: Global Using PowerShell

  • A result like the one below will be displayed when the installation is finished.
  • To update the PATH variable, use the cat command listed below. By adding the PowerShell installation path to the PATH environment variable, you can run PowerShell from any directory using this command.
  • In your terminal session, type the command below to update the environment variable.

zsh -l

  • To start PowerShell, enter the command pwsh in your terminal.

pwsh

That’s it! You now have PowerShell installed on your Mac, and you can begin using it for your scripting and automation needs. Keep in mind, however, that PowerShell for Mac is not exactly the same as the Windows version, with some features and modules excluded, but it still has its place and is useful to have.

PowerShell core

PowerShell version 5.1 is the most recent version of the original PowerShell. Starting with version 6.0, it is now called a PowerShell core. PowerShell Core is free and can be used on Windows, Linux, and Mac, among other systems. It’s based on the.NET core. Windows users start PowerShell Core as pwsh, while Linux and Mac OS X users start it as pwsh. Also, PowerShell Core version 6.0 came out for the first time on August 18, 2016.

By default, the standard MSI installer methods will install PowerShell Core on your computer in the 64-bit Program Files directory. This won’t replace Windows PowerShell; instead, it will work right alongside PowerShell and include the latest changes to it.

PowerShell Core: Step-by-Step Guide

There are multiple ways to install PowerShell on Windows. Each install method is designed to support different scenarios and workflows. Choose the method that best suits your needs.

#1. PowerShell Core Installation

In this part, we’ll show you how to install PowerShell Core on different platforms, set up an integrated development environment with Visual Studio Code, and use MSI to install Windows Terminal for a better PowerShell experience. You must first install PowerShell Core on your computer in order to begin using it. Follow the steps for installing on the device that works for you.

  1. For Windows

Visit the GitHub updates page to download the most recent version of PowerShell Core. Pick the right MSI installer (x64 or x86) for your machine, and then follow the steps in the installation wizard.

  1.  MacOS

Use Homebrew to install PowerShell Core. Run the following command from a terminal:

Running brew install –cask PowerShell

  1.  Linux

Some versions of Linux, like Ubuntu, Debian, CentOS, and Fedora, can have PowerShell Core installed. Refer to the official install documentation for your distribution for detailed directions on how to install.

#2. Installing PowerShell and Visual Studio Code Add-Ins for an Integrated Development Environment (IDE)

Many people use Visual Studio Code (VSCode), which is a flexible code tool that works well with PowerShell Core. Take the following steps to set up an integrated development environment:

  • You can download and install Visual Studio Code for free
  • By clicking on the O button on the left side of the window or by pressing Ctrl+Shift+X, you can access the Extensions view.
  • You can find the “PowerShell” application by Microsoft and install it.
  • Finally, you now have a powerful IDE that lets you write and fix bugs in PowerShell Core scripts.

#3. Install PowerShell Core on Windows Using MSI

You can use the following steps to install the PowerShell core on the Windows operating system using MSI:

  • First, download the MSI file from the GitHub page of the PowerShell. Click on the following link to download:

https://github.com

  • Now, go to the Get PowerShell and click on the.msi link according to the version of your system from the download (stable) column.
  • Click on the downloaded file to install it. After clicking, the following setup wizard will appear: To continue to install, click on the Next
  • The following window shows you a default installation path for PowerShell. If you want to change it, then change it according to your choice; otherwise, click on the Next
  • Again, click on the Next button after selecting the options according to your needs. And click on the Install
  • After installation, the PowerShell core was successfully installed on your computer system.

#4. Installing Windows Terminal for a Better PowerShell Experience 

Windows Terminal is a contemporary, customizable terminal program that makes it easier to use PowerShell Core and other command-line tools. Follow these steps to install Windows Terminal on your Windows system:

  • Search for “Windows Terminal” on the Microsoft Store or go directly to the Windows Terminal page.
  • To download and install Windows Terminal, click the “Get” button.

After installing PowerShell Core, launch Windows Terminal and begin using it by opening a new PowerShell Core tab or making it the default shell.

Can you learn PowerShell on Mac?

Yes, PowerShell is not just for Windows anymore; it now runs on Linux and macOS too

Is Bash better than PowerShell?

PowerShell is the best choice for managing Windows workloads

Which shell is best for macOS?

Mac’s default shell is either zsh (Z shell) or bash (Bourne-again Shell).

How do I know if PowerShell is installed on my Mac?

Mostly on Mac, the PowerShell version would be 2.0 or 1.0. So the user has to check the registry or key location by giving the following command: HKEY _ LOCAL_MACHINE \software\powershell\microsoft\1- PowerShell engine.

In Summary

We hope this article has inspired you to dive deeper into the world of PowerShell Core and continue learning about its many features and capabilities. Also, don’t forget to consult the official PowerShell Core documentation and other resources, such as tutorials and community forums, to further your knowledge and expertise in this powerful tool.

References

  1. How to Install Git on Windows: Easy Step-by-Step
  2. HOW TO CODE IN PYTHON: Step-By-Step Guide
  3. POWERCHART: Overview, Features, Competitors & More 2023
  4. HOW TO INVERT COLOURS ON IPHONE: Easy Tips That Do the Trick
  5. How to Delete an Outlook Email Account: All You Need
0 Shares:
Leave a Reply

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

You May Also Like