Mac OS

How to upgrade PowerShell to the latest version on macOS

PowerShell-1

PowerShell is a cross-platform task automation solution that runs on Windows, Linux, and macOS. It includes a command-line shell, an associated scripting language, and a framework for processing cmdlets. There are several ways to install PowerShell on macOS. If you wish to install PowerShell via Homebrew package manager for macOS, please see “how to install and uninstall PowerShell on macOS“. I would also like to discuss Homebrew as it is a package manager on macOS. Homebrew is a package manager for Macs which makes installing lots of different software like Git, and Note++ easy. The steps below are ways to install PowerShell on macOS. Kindly refer to these guides on how to install Windows Package Manager (Winget CLI), how to install, upgrade and uninstall Chocolatey, how to install, upgrade and uninstall software with Chocolatey, and how to install applications Windows Package Manager-Winget CLI.

Note: PowerShell 7.1 is an in-place upgrade that removes PowerShell Core 6.x and 7.0. The /usr/local/microsoft/powershell/6 folder is replaced by /usr/local/microsoft/powershell/7. 
- If you need to run an older version of PowerShell core side-by-side with PowerShell 7.1, install the version you want using the binary archive method. When new versions of PowerShell are released, update Homebrew and upgrade PowerShell. As you can see below, there is a notice that PowerShell v7.1.0 is available and I am currently running v7.0.3.
Screenshot-2021-04-15-at-03.17.39

Launch PowerShell using spotlight search. There are different ways to launch PowerShell on macOS. When new versions of PowerShell are released, you should update Homebrew’s formulae first as shown below.
– During the installation, you may be asked to fix the use of shallow clone due to its cost. just run the command as shown below.

brew update
Screenshot-2021-04-15-at-03.28.51

Next, we will have to upgrade PowerShell. Because I installed PowerShell appending “cask” to it, I will also upgrade PowerShell this way as it is recommended instead of just using “brew upgrade PowerShell”.

Whether you use the cask or the tap method, when updating to a newer version of PowerShell, use the same method you used to initially install PowerShell. If you use a different method, opening a new pwsh session will continue to use the older version of PowerShell. If you do decide to use different methods, there are ways to correct the issue using the Homebrew link method.
Screenshot-2021-04-15-at-03.33.29

Now the upgrade is complete. PowerShell shell must be exited and restarted to complete the upgrade and refresh the values shown in $PSVersionTable. You can use the below command as well.

pwsh
Screenshot-2021-04-15-at-03.41.51

I hope you found this blog post helpful. If you have any questions, please let me know in the comment session.

Subscribe
Notify of
guest
1 Comment
Inline Feedbacks
View all comments
dunxd
2 months ago

I installed PowerShell on my Mac some time ago, and I don’t recall if I used cask or tap. How can I find that out?

1
0
Would love your thoughts, please comment.x
()
x