Installing PowerShell

Installing

If you need to update PowerShell, so for example, you need PowerShell 4.0 on Windows Server 2008 R2 then How to Install Windows PowerShell 4.0 - TechNet Articles is a very useful article.

Whether you are running on Windows or not you should seriously consider installing PowerShell Core as this is the cross platform version and it runs on Windows quite happily along side versions 4 and 5, see Installing PowerShell | Microsoft Docs for detailed instructions.

When installing PowerShell on a Mac I would recommend using the Homebrew-Cask command:
brew cask install powershell which is fully explained at Installing PowerShell Core on macOS | Microsoft Docs.

Updating

Windows

With PowerShell Core, I would just install the MSI without doing an uninstall first. I did note when installing PowerShell 6.2.1 over PowerShell 6.1.2 that picking the install directory of "D:\Program Files\PowerShell" actually installed into "D:\Program Files\PowerShell\6" which is where 6.1 was.

MacOS

Assuming you installed with HomeBrew then just follow the upgrade steps at Installing PowerShell Core on macOS | Microsoft Docs, which is as follows:
brew update
brew upgrade powershell

The link is provided in case this changes.