Как проверить версию power shell


Updated:
03 Nov, 23



by

How to Check PowerShell Version?

List of content you will read in this article:

One fundamental aspect of harnessing the power of PowerShell is understanding the version you’re working with. Knowing your PowerShell version serves as a compass in your journey through the scripting landscape. It not only enables you to gauge whether you’re using the latest and most feature-rich iteration but also ensures compatibility with the diverse array of scripts and modules that might be integral to your projects. In this guide, we’ll explore the importance of checking your PowerShell version and provide step-by-step instructions onhow to check Powershell version Windows 7 and Linux systems.

How to Check Your PowerShell Version on Windows?

1. Open a PowerShell Console

To begin, you need to open a PowerShell console. Here’s how you can do it:

  • How to check the PowerShell version in Windows 10 and Windows 11: Click on the Start menu and begin typing “powershell.” As you type, you’ll see “Windows PowerShell” in the list of search results. Click on it to open the PowerShell console. You’ll now have an open PowerShell window ready for your commands.

2. Type the Following Command

This command accesses the $PSVersionTable variable, which contains detailed information about your PowerShell version and configuration.

3. Press Enter

Once you’ve entered the command, press the “Enter” key on your keyboard. PowerShell will process your request and display the results directly in the console window.

The information displayed will include details such as the major and minor version numbers, the build number, and more. This information is crucial to check the PowerShell version and its capabilities.

How to check your PowerShell version on Linux?

To check the PowerShell version on Linux:

  1. Open a Terminal Window
    • Launch a terminal window on your Linux machine. This can usually be done by searching for “Terminal” in your application launcher or using the keyboard shortcut.
  2. Type the Following Command
  1. Press Enter
    • After entering the command, press the “Enter” key on your keyboard.
  2. View the Version Information
    • The terminal will display your PowerShell version, providing details such as the major and minor version numbers, build number, and other relevant information.

How to update your PowerShell version?

For Windows:

  1. Update Windows Operating System
    • PowerShell updates are often included in Windows updates. Therefore, the first step is to ensure that your Windows operating system is up-to-date. To do this, go to “Settings” > “Update & Security” > “Windows Update,” and check for updates. Install any available updates.
  2. Download and Install PowerShell Core (Windows PowerShell 5.1)
    • If you want to update Windows PowerShell 5.1 to a newer version (e.g., PowerShell 7), download the latest release of PowerShell Core (which is the open-source version of PowerShell) from the official PowerShell GitHub repository or the Microsoft website.
  3. Use Windows Terminal (Optional)
    • To manage multiple PowerShell versions or use PowerShell Core alongside Windows PowerShell, consider using Windows Terminal. It allows you to switch between different PowerShell versions and other command-line tools seamlessly.

For Linux:

  1. Update Package Lists
    • Open your terminal and update the package lists for your Linux distribution. The exact command may vary depending on your distribution. For example, on Debian/Ubuntu, you can use:

sudo apt update

  1. Upgrade PowerShell
    • Use your distribution’s package manager to upgrade PowerShell. Again, the command varies by distribution. For Debian/Ubuntu, you can use:

sudo apt install powershell

sudo yum install powershell

sudo zypper install powershell

  1. Alternatively, Install PowerShell Core (Linux)

Troubleshooting problems by checking your PowerShell version

If you encounter any issues while attempting to check the PowerShell version on Windows, here are some troubleshooting steps to help you resolve them:

Advanced PowerShell Version Management Techniques

After completing the check PowerShell version process, for those seeking to take their PowerShell version management skills to the next level, advanced techniques can provide greater control and flexibility. Here are some advanced PowerShell version management techniques to consider:

  1. Multiple PowerShell Versions: If you work on a system that requires different PowerShell versions, consider installing multiple versions side by side. This allows you to switch between versions as needed. Tools like Windows Terminal can be helpful in managing and switching between PowerShell instances efficiently.
  2. PowerShell Version Control: Just as you might use version control systems like Git for your code, consider version control for your PowerShell scripts. This ensures that your scripts are compatible with specific PowerShell versions and allows for easy tracking of changes.
  3. Module Versioning: When working with PowerShell modules, pay attention to module versioning. Module authors often specify which PowerShell versions their modules are compatible with. Be sure to use the appropriate module version for your PowerShell environment.
  4. PowerShell Profiles: Customize your PowerShell experience using profiles. PowerShell profiles are scripts that run when you start a PowerShell session. You can have different profiles for different PowerShell versions, enabling version-specific configurations and settings.
  5. PowerShell Remoting: PowerShell remoting allows you to execute PowerShell commands on remote systems. When dealing with multiple systems with different PowerShell versions, remoting can help you manage and update PowerShell versions across multiple machines simultaneously.
  6. Docker Containers: Consider using Docker containers to isolate PowerShell environments. Docker allows you to create containers with specific PowerShell versions, ensuring that your scripts run consistently across different systems. 
:/>  Управление электропитанием windows 7

Why is it important to know your PowerShell version?

Understanding your PowerShell version is crucial for several reasons:

  • Compatibility: Certain scripts, modules, and cmdlets may require specific PowerShell versions to function correctly. Knowing your version helps ensure that you can execute these components without compatibility issues.
  • Security: Keeping your PowerShell up-to-date is essential to receive security updates and patches. Knowing your version ensures you’re aware of potential vulnerabilities that have been addressed in newer releases.
  • Feature Availability: Newer PowerShell versions often introduce valuable features and improvements. Knowing your version helps you leverage these enhancements in your scripting and automation tasks.
  • Staying Current: In the rapidly evolving IT landscape, it’s essential to stay current with technology. Knowing your PowerShell version allows you to adapt to changes and utilize the latest tools and capabilities.
  • Troubleshooting: When encountering issues with PowerShell scripts or modules, knowing your version is the first step in diagnosing problems. It helps identify whether the issue is related to the version of PowerShell you’re using.
  • Compatibility with Platforms: If you work on multiple platforms, such as Windows, Linux, or macOS, knowing your PowerShell version ensures compatibility with the platform-specific variations (e.g., Windows PowerShell, PowerShell Core) and helps streamline cross-platform tasks. 

Benefits of using the latest version of PowerShell

Using the latest version of PowerShell offers several benefits that can enhance your scripting, automation, and system management capabilities. Here are some key advantages of upgrading to the latest PowerShell version:

  • Access to New Features and Enhancements: Each new version of PowerShell introduces various features and improvements. These enhancements can streamline your scripting tasks, making them more efficient and easier to manage.
  • Improved Performance: Newer versions of PowerShell often come with performance optimizations, which can lead to faster execution of scripts and commands. This can be particularly advantageous for time-sensitive tasks.
  • Enhanced Security: Microsoft frequently releases security updates and patches for PowerShell. Staying up-to-date with the latest version ensures that you benefit from the latest security features, protecting your system from potential vulnerabilities.
  • Compatibility: Some scripts and modules may require specific PowerShell versions to function correctly. Using the latest version ensures compatibility with a broader range of scripts and modules, reducing compatibility issues.
  • Increased Stability: Over time, bugs and issues are identified and resolved in PowerShell. Newer versions tend to be more stable and reliable, reducing the likelihood of encountering unexpected errors.

Keeping your PowerShell up-to-date offers numerous benefits, including access to new features, better performance, enhanced security, and script/module compatibility. To ensure you’re using the latest version, regularly update your Windows OS (for Windows PowerShell) or check and update PowerShell Core on Linux using pwsh –version

For ongoing support and in-depth information, refer to Microsoft’s official, participate in thePowerShell Community Forum, or explore thePowerShell GitHub Repository. These resources will empower you to further hone your PowerShell skills and elevate your system management and automation prowess. Stay informed and embrace the power of automation to optimize your IT tasks.

Nasiruddin Ahmed

Photo by Warren Umoh on Unsplash

Are you a PowerShell pro? If not, then it’s useful to understand how to check your PowerShell version as a beginner. In this detailed guide, we’ll explain how to check PowerShell easily.

Key Take Away

  • In this article, we explore four simple methods to check the PowerShell version.
  • Most of the methods are easy and quickly offer the solution.
  • PowerShell is a tool for IT professionals to manage and automate administrative tasks.
:/>  Ночной свет - здоровью вред: миф или реальность?

How to Check Your PowerShell Version

Let’s easily check what version of PowerShell is installed on your device.

  • Go to the Start menu, search ‘powershell’, and Launch PowerShell.

After launching PowerShell, you will get a screen like the one below:

Now, here we’ll use some of the commands to check the PowerShell version.

Let’s discuss 4 ways to check the Windows 11 PowerShell version.

The Get-Host command

Let’s use the primary command in PowerShell to find out the version. The command is: get-host.

But what is get-host? Here, the host is a program hosting the PowerShell engine. It means the get-host command returns the host version.

As you can see below, the command displays information like the name of the host, current culture, and UI culture.

The PowerShell version mentioned below is 5.1.22621.2506.

The $host.Version command

If you run the command $host.Version or (Get-Host).Version, You will get a similar result as we got with the get-host command.

The $PSVersionTable command

This is the most reliable method to check the PowerShell version in your system. Like the above three, it’s a simple command: $PSVersionTable, and press Enter. This command will also display a list of information. The first one on the list is the PowerShell version, in this case, it is 5.1.

The $PSVersionTable returns specific information about the PowerShell engine version. It also displays the edition running on your system — core or desktop, to define the PowerShell edition. You can use this read-only automatic variable on a remote computer.

The Registry

In this method, you can use the Registry Editor to check the PowerShell version in your system.

Now, there are two ways to identify the PowerShell version using the Registry Editor:

  • One, you can simply type in the command
  • Two, you can open the Registry Editor app to find the PowerShell version.
(Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine -Name 'PowerShellVersion').PowerShellVersion

Now, you have to click a few boxes to check the PowerShell version in your system.

  1. First, click the Software folder under HKEY-LOCAL-MACHINE, or HKLM folder.
  2. Now, search Microsoft in the software vendors list.
  3. Click the Microsft folder and search PowerShell
  4. Under PowerShell, there will be two folders: 1 and 3, click on 3.
  5. Then select PowerShell Engine
  6. On the right, you’ll see a list of information along with the PowerShell version.

That’s it. These are the four ways to check the PowerShell version installed in your system.

How to check the PowerShell version on your remote computer?

Here, you can change the computer name with your specific computer name, and voila! It will return the PowerShell version information.

Quick Links

Key Takeaways

To check the version of PowerShell you are using on Windows 10, open a PowerShell window and enter “$PSVersionTable” into the prompt. The current PowerShell version will be displayed next to “PSVersion.”

Finding your PowerShell version helps you know what PowerShell features you have access to. A PowerShell command lets you reveal the version number, and we’ll show you how to do this.

Find Your PowerShell Version

You’ll use the PowerShell utility itself to find the version number.

To start, open the “Start” menu, search for “Windows PowerShell,” and click it in the search results.

Search for "PowerShell" in the Start Menu.
$PSVersionTable
Enter "$PSVersionTable" to see your PowerShell version.

PowerShell displays various numbers. Here, the first value that says “PSVersion” is your PowerShell version.

The version of PowerShell you're currently using will be the first entry.

You can now close the PowerShell window.

How to Get PowerShell 7 Version

To check your PowerShell 7 version on Windows 10, just open up PowerShell 7 and look at the very first line in the window. It prints the PowerShell version every time you open a new instance.

PowerShell 7 displays the version number every time you open it.
$PSVersionTable 
The output of $PSVersionTable in PowerShell 7.

Get PowerShell Version with the get-host Command

Only use this if you’re checking your

local

PowerShell version.

To use the get-host command to check your PowerShell version, open up any version of PowerShell, then enter:

get-host
The results of get-host in PowerShell 7.

Find PowerShell Version Using the $Host variable

The $host variable is automatically set when you open PowerShell, all we need to do is query the version. Once again, open up PowerShell, then enter:

$host.version

You’ll see your version number displayed in a neat little table.

The output of $host. Version.

You can also just run $host if that is more to your liking, but it contains additional information that you may not care about, much like the get-host command.

:/>  $RECYCLE.BIN что это за папка на Windows?
The full output from the $host command.

Check Your PowerShell Version in the Windows Registry

You can also check your PowerShell version from the Windows registry. First, open up the Start Menu, then search for and launch “Regedit.”

Open the Registry Editor through the Start Menu.
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft

Scroll down through the list until you see the PowerShell listings. As you might expect, PowerShell 5 and PowerShell 7 are in slightly different locations. It is also possible that future iterations will be stored in slightly different locations. If our specific paths don’t work, just look around through the PowerShell keys until you find entries that talk about versions. They’ll be very similar to the examples we attached below.

PowerShell 5 is located in:

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine

Then check the “PowerShellVersion” entry to get your exact version number.

The Registry entry for PowerShell 5.

PowerShell 7 is directly below in our case (and likely will be for you too). The version information can be found in:

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShellCore\InstalledVersions\31ab5147-9a97-4452-8443-d9709f0516e1​​​​​​​

Your PowerShell 7 version is displayed next to the “SemanticVersion” entry.

The PowerShell 7 version displayed in the Registry.

Update PowerShell in Windows 10

Windows 10 updates the built-in PowerShell tool when you install system updates. This means that you should keep your PC up to date to ensure that you’re always running the latest version of PowerShell.

Also, know that PowerShell 7 is different from the version that’s usually installed on Windows 10 PCs. To install this version of PowerShell, either download the installer file or run a command from PowerShell on your PC.

Different versions of PowerShell have different features and capabilities. So, it is good to know the versions of PowerShell you are using. In this tutorial, I will show you how to check PowerShell version using different methods.

To check your PowerShell version, open PowerShell and type $PSVersionTable.PSVersion to see the version details. Alternatively, you can use Get-Host by typing Get-Host and looking for the Version property, or use Get-Command with (Get-Command powershell).Version. On Windows, you can also check the version in the Registry Editor under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine. For PowerShell Core on Linux or macOS, type pwsh –version in the terminal.

Get the PowerShell version using different methods

Method 1: Using $PSVersionTable

The easiest ways to check your PowerShell version is by using the $PSVersionTable automatic variable. This variable contains a lot of useful information about your PowerShell environment, including the version.

Here is the command.

$PSVersionTable.PSVersion

You can see the screenshot below. I executed the above command using VS code. It shows me the PowerShell version.

Check PowerShell Version

Method 2: Using Get-Host

The Get-Host cmdlet provides information about the current host program, including the version of PowerShell.

Get-Host

The output is shown in the screenshot below. It provides a lot of information, including the PowerShell version. This time, I executed the script using Windows PowerShell ISE.

Name : Windows PowerShell ISE Host
Version : 5.1.22621.2506
InstanceId : aaa160fc-9465-4e39-84aa-2737f3b88c08
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : en-IN
CurrentUICulture : en-US
PrivateData : Microsoft.PowerShell.Host.ISE.ISEOptions
DebuggerEnabled : True
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace

Here the Version property indicates the PowerShell version.

How to Check PowerShell Version

Method 3: Using Get-Command

You can also use the PowerShell Get-Command cmdlets to get the PowerShell version. Below is the complete command.

(Get-Command powershell).Version

Method 4: Checking the Registry (Windows Only)

If you have knowledge about the Windows Registry, you can also check the PowerShell version there.

Here are the steps:

  1. Press Win + R, type regedit, and press Enter to open the Registry Editor.
  2. Navigate to the following path:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine
  3. Look for the PowerShellVersion entry, which will display the version.

Method 5: Using PowerShell Core on Linux or macOS

If you are using PowerShell Core on Linux or macOS, you can check the version using the pwsh command.

Here are the steps:

  1. Open Terminal.
  2. Type the following command and press Enter:pwsh --version
  3. The terminal will display the PowerShell version:PowerShell 7.4.0

Conclusion

In this tutorial, I have explained different methods to get the PowerShell version:

  • Using $PSVersionTable
  • Using Get-Host
  • Using Get-Command
  • Checking the Registry (Windows Only)
  • Using PowerShell Core on Linux or macOS

You may also like: