How to Upgrade Powershell Version on Windows Server 2012 R2

PowerShell is a command-line shell and scripting language developed by Microsoft Corporation for executing, automating and managing tasks in Windows operating systems. It is widely used by system administrators, developers, and IT professionals who seek to simplify repetitive administrative tasks and automate complex workflows on Windows platforms.

As organizations look for ways to boost productivity and efficiency, PowerShell is gaining wider adoption as a powerful automation tool. If you are a server administrator, you may need to upgrade your PowerShell version to take advantage of new features and improve performance. In this article, we will show you how to upgrade your PowerShell version on Windows Server 2012 R2, a popular version of the Windows server platform.

Video Tutorial:

Why You Need to Upgrade PowerShell Version on Windows Server 2012 R2

With every new version of PowerShell, Microsoft introduces new features and improvements that can enhance the functionality of your Windows servers. Upgrading your PowerShell version can offer the following benefits:

  1. Improved Security: Newer PowerShell versions are built with better security features to protect your Windows servers and data.
  2. Bug Fixes: Each new version of PowerShell addresses known issues and bugs, which can improve the stability of your Windows servers.
  3. New Features: PowerShell releases often include new features that can help you automate tasks more efficiently and effectively.
  4. Higher Performance: Newer PowerShell versions are optimized for performance, so upgrading can help you improve the speed and responsiveness of your Windows servers.

Method 1: Upgrade PowerShell via Windows Update

If you have automatic Windows Update enabled, then upgrading PowerShell is as simple as running Windows update. Windows update will detect the latest version of PowerShell available and automatically download and install it for you.

  1. Open the Start Menu and search for "Windows Update".
  2. Click on "Check for Updates".
  3. Windows will check for available updates and display them. Look for any updates related to PowerShell and click "install" to upgrade your PowerShell to the latest available version.
  4. Wait for the update to complete and restart your server if needed.

Pros:

  • Easy and straightforward process.
  • No need to manually download and install anything.
  • Windows Update is a trusted source, so you don’t need to worry about malware.
  • Automatic Windows Update can keep your Windows server up-to-date with the latest security patches and updates.

Cons:

  • Windows Update may not always detect the latest version of PowerShell available.
  • The update process may take longer if there are other updates pending.
  • Manually selecting the PowerShell update requires active monitoring of the update process.

Method 2: Upgrade PowerShell via PowerShell Gallery

PowerShell Gallery is a centralized repository for PowerShell modules and scripts. You can use PowerShell Gallery to download and install the latest version of PowerShell on your Windows server.

  1. Open PowerShell as an Administrator.
  2. Run the following command to check if there is a newer version available:
    Find-Module PowerShellGet | Install-Module
  3. Run the following command to install the new version of PowerShell:
    Install-Module -Name PowerShellGet -Force
  4. The latest version of PowerShell should now be installed. Verify by running the following command:
    Get-Host | Select-Object Version

Pros:

  • PowerShell Gallery always contains the latest version of PowerShell.
  • You can install PowerShell version without needing to update from Windows Update feature.
  • PowerShell Gallery can offer more PowerShell resources beyond the PowerShell core itself.

Cons:

  • You need an active internet connection to download the newer PowerShell version from PowerShell Gallery.
  • Manually upgrading PowerShell via PowerShell Gallery can take more time than the automatic Windows Update.

Method 3: Upgrade through Microsoft’s Installer Package

Microsoft makes available a package (installer file) that can upgrade PowerShell to the latest available version. You can use this package to upgrade PowerShell on Windows Server 2012 R2.

  1. Download the latest version of PowerShell from Microsoft’s Download Center website.
  2. Run the installer package and select the default settings, unless you want to change the configuration.
  3. Wait for the installer to complete and restart the server.
  4. Verify that PowerShell is upgraded to the latest version by opening PowerShell as an Administrator and running the following command:
    Get-Host | Select-Object Version

Pros:

  • You can download and install the newer PowerShell version anytime and anywhere.
  • You can control PowerShell’s install configurations, i.e. if you are administering a server farm, this might be very useful in some cases.
  • Microsoft’s download center resources are generally more reliable for carrying-out installations.

Cons:

  • You have to download and install the package manually.
  • You need to actively monitor the installation process.
  • Since you are manually downloading and installing the package, you will lose the "automatic updates" feature (as in Method 1).

What to Do If You Can’t Upgrade PowerShell?

Some factors may prevent upgrading PowerShell to newer versions. If you encounter such errors, you can try the following measures:

  • Disable Execution Policy: Execution policies may prevent PowerShell from running installation commands. You can temporarily disable the policy by running the command:
    Set-ExecutionPolicy Unrestricted
  • Check Management Framework Components: Management Framework components (which may include PowerShell) may be required to be installed on the server. If not included, you can need to install Windows Management Framework via Windows Update or manually download and install them from Microsoft’s download center.
  • Check PowerShell Dependencies: PowerShell is dependent on certain system files and settings, including .NET Framework components. Make sure you have the right components installed in your server system.
  • Check Compatibility Issues: Newer PowerShell versions may have compatibility issues with some applications. Validate with your application supplier for compatibility.
  • Backup: If you still can’t upgrade PowerShell and it is a critical component in your infrastructure, back-up your PowerShell scripts, modules and configurations before attempting to repair or reinstall PowerShell.

Bonus Tip: Enable PowerShell Tab Completion

Tab completion is a great productivity feature in PowerShell that allows you to type part of a command and then press the "Tab" key to automatically complete the command. If you don’t use this feature, you might be missing out on a faster way to enter commands.

  1. Open PowerShell as an Administrator.
  2. Type the following command and press "Enter":
    Set-PSReadLineOption -EditMode Windows
  3. Tab completion should now be enabled.

5 FAQs

Q1: Why is PowerShell Upgrade Needed?

A: Upgrading PowerShell ensures that you are running a version of PowerShell that is optimized for performance, has the newest features and bug-fixes, and is more secure. It is also needed to smoothly support newer applications and workloads.

Q2: Is it possible to install multiple versions of PowerShell on the same system?

A: Yes. Multiple versions of PowerShell can be installed on the same system. However, this is generally not recommended unless for specific reasons like installing Beta or release candidates PowerShell versions.

Q3: Do I need to restart my system after upgrading PowerShell?

A: Yes. Restarting your system after installing or updating PowerShell is necessary to ensure that all the necessary processes required by PowerShell are initialized appropriately.

Q4: Will PowerShell scripts break down after upgrading PowerShell?

A: Your existing scripts may or may not break down. Newer versions of PowerShell are generally backwards-compatible, but you should validate that your present scripts execute correctly in the new version after upgrading.

Q5: Can the upgrade process roll-back to the previous version of PowerShell?

A: PowerShell upgrade process is non-revertible, making it almost impossible to roll back to the previous version once PowerShell has undergone an upgrade. It is recommended to keep a backup before upgrading PowerShell.

Final Thoughts

Upgrading PowerShell is an essential process that sometimes becomes a critical part of daily system maintenance. Doing it right way ensures your PowerShell capabilities for effective administration, task automation and workflow becomes optimized. With the three explained methods (and possible limitations encountered), you can be confident to upgrade PowerShell version on your Windows Server 2012 R2 platform successfully.