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

Learn to display your current PowerShell version with this short guide

It’s easy to find out which version of PowerShell you are using on Windows 10 and 11. You can check the version by running simple commands, using the registry, or by signing in remotely. This wikiHow article will show you how to check your PowerShell version and teach you how to upgrade PowerShell to the latest version.

  1. Open PowerShell.
  2. Type $PSVersionTable and press Enter.
  3. Find the PowerShell version next to “PSVersion.”
  1. Step 1 Open PowerShell.

    There are multiple ways that you can run PowerShell:

    • Press the Win key and search for PowerShell, and then click the system result.
    • Press Win + X to open a menu and click PowerShell. However, you can change “PowerShell” here to “Command Prompt,” so this method may not work for you.
    • This is the easiest and fastest method to find your PowerShell version.
  2. Step 2 Type $PSVersionTable into PowerShell and press ↵ Enter.

    Pressing Enter sends the command.

  3. Step 3 Look for your PowerShell version number.

    It’s next to “PSVersion”.

    • Version 5.1 is the last supported Microsoft version, so that’s most likely what your updated computer has.
    • You can also use the commands get-host and $host.version, but those are less likely to give accurate answers. Use the $PSVersionTable command for the best results.
  1. Step 1 Open Registry Editor.

    Press the Win key, type regedit, and click the app result.

  2. Step 2 Go to Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.

    You can enter that into the address bar or navigate the different folders.

  3. Step 3 Check your version of PowerShell.

    Look for subfolders that indicate your version of PowerShell.

    • For example, PowerShell 5 is in PowerShell\3\PowerShellEngine.
    • PowerShell 7 is in PowerShellCore\InstalledVersions\31ab5147-9a97-4452-8443-d9709f0516e1.
  1. Step 1 Run winrm quickconfig on the remote computer as an Administrator.

    You need to do this so the computer will let you use PowerShell remotely.

  2. Step 2 Type the following command and press ↵ Enter:

  3. Step 3 Look for the PowerShell version number.

    It’s next to “PSVersion”.

  1. To upgrade PowerShell, you'll need to update Windows.

    By updating Windows, you’ll also update your PowerShell version if you have an out-of-date one.

    • This method will not update you to PowerShell 7. To get that version, you can find it in Github where you can download the version for your OS.[2]

Ask a Question

200 characters left

Include your email address to get a message when this question is answered.

Thanks for submitting a tip for review!

About This Article

Thanks to all authors for creating a page that has been read 4,950 times.

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.

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.


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. 

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.

While working with files in PowerShell, you may get requirements to check if a file contains a specified string. PowerShell provides different methods to check if a file contains a string. Let us check each method with examples.

To check if a file contains a specific string in PowerShell, you can use the Select-String cmdlet with the -Pattern parameter specifying your search term, and the -Path parameter to define the file’s location. For a simple true or false return, add the -Quiet switch. For example: $containsString = Select-String -Path “C:\MyFolder\MyFile.txt” -Pattern “searchTerm” -Quiet will return True if “searchTerm” is found, otherwise False.

I am using Visual Studio code to execute all the PowerShell scripts. You can also use Windows PowerShell ISE to execute the examples.

And for each method, I will take a .txt file.

Now, let us check various methods of PowerShell to check if a file contains a specific string.

1. Using the Select-String Cmdlet

The Select-String cmdlet in PowerShell is similar to the grep command in Unix or Linux. This command you can use to search for text patterns within files. It uses regular expression matching to search for text patterns in input strings and files.

Here’s a simple example of how to use Select-String in PowerShell to check if a file contains a specific string.

Select-String -Path "C:\MyFolder\MyFile.txt" -Pattern "powershellfaqs"

This command searches for the string “powershellfaqs” in the file “MyFile.txt” located in “C:\MyFolder”. If the string is found, Select-String will return the line or lines containing the string, along with some additional context information.

The screenshot below shows that this file contains the string twice and displays both lines.

Check if a File Contains a String in PowerShell

2. Check for a String in Multiple Files in PowerShell

Sometimes, you may want to check for a sting in all the files in the folder, and this is easy to do in PowerShell.

To check for a specific string across multiple files in PowerShell, you can combine Get-ChildItem with Select-String:

Get-ChildItem -Path "C:\MyFolder\*.txt" | Select-String -Pattern "powershellfaqs"

This script searches for “powershellfaqs” in all text files within “C:\MyFolder”. It lists any files containing the string, along with the lines where the string was found.

3. Using the -Quiet Switch

This is another simple method if you just want to know if the string is presented in the file or not in PowerShell. It just returns true or false.

If you only need to know whether the string exists in the file and don’t need to see the specific lines, you can use the -Quiet switch in PowerShell. This will return a boolean value: True if the string is found, and False otherwise.

$containsString = Select-String -Path "C:\MyFolder\MyFile.txt" -Pattern "powershellfaqs" -Quiet
$containsString

Here, you can see the output in the screenshot below; it returns true as the string is presented in the file.

How to Check if a File Contains a String in PowerShell

4. Checking if a String Exists with -match Operator

Here is also another method to check if a string exists within a file is to use the -match operator in PowerShell. First, you’ll need to read the file content into a variable and then use -match to search for the string.

$content = Get-Content -Path "C:\MyFolder\MyFile.txt"
$containsString = $content -match "powershellfaqs"

This approach is useful when you want to perform additional operations on the file content after checking for the string.

5. Using .Contains() Method

This is another simple method to check if a string contains in a file in PowerShell. In PowerShell, you can use the .Contains() method on a string object. After reading the file into a variable, you can check if the string contains your specified term.

$content = Get-Content -Path "C:\MyFolder\MyFile.txt" -Raw
$containsString = $content.Contains("powershellfaqs")

Note that .Contains() is case-sensitive. For a case-insensitive search, you can convert both the content and the search term to the same case using .ToLower() or .ToUpper().

Here is the PowerShell script for case-insensitive search.

$content = Get-Content -Path "C:\MyFolder\MyFile.txt" -Raw
$lowercaseContent = $content.ToLower()
$containsString = $lowercaseContent.Contains("powershellfaqs".ToLower())

6. Using -like Operator with Wildcards

In PowerShell, the -like operator allows you to use wildcards for pattern matching. This can be useful when you want to check if a string contains a specific word or pattern.

$content = Get-Content -Path "C:\MyFolder\MyFile.txt"
$containsString = $content -like "*powershell*"

The asterisks * are wildcards that represent any number of characters. This command will return True if “powershell” is found anywhere in the content.

7. Using Regular Expressions

In PowerShell, you can also use regular expressions to do a pattern-matching search. You can use regular expressions with Select-String. This allows you to search for complex patterns within the text.

Select-String -Path "C:\MyFolder\MyFile.txt" -Pattern "powershell\w+"

Conclusion

PowerShell provides several methods to check if a file contains a specific string or pattern. In this PowerShell tutorial, I have explained with examples how to check if a file contains a string using the below methods:

  1. Using the Select-String Cmdlet
  2. Check for a String in Multiple Files in PowerShell
  3. Using the -Quiet Switch
  4. Checking if a String Exists with -match Operator
  5. Using .Contains() Method
  6. Using -like Operator with Wildcards
  7. Using Regular Expressions

You may also like:


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:

:/>  ROUTE - Обработка таблиц сетевых маршрутов.