To find your PowerShell version, type $PSVersionTable into the PowerShell console and press Enter. This command displays a table of version information, where the PSVersion line shows the exact version number currently running on your system.
Knowing your version is essential because different versions of PowerShell (such as Windows PowerShell 5.1 and PowerShell 7) have different capabilities, modules, and syntax requirements. While Windows PowerShell is built into Windows, PowerShell 7 is a cross-platform version that must be installed separately.
What You'll Need
- A computer running Windows, macOS, or Linux (depending on which version of PowerShell you have installed).
- Access to the PowerShell console or terminal.
Step-by-Step
- Open PowerShell:
- On Windows: Click the Start menu, type "PowerShell," and select Windows PowerShell or PowerShell 7 from the results.
- On macOS or Linux: Open your terminal application and type
pwshto launch the PowerShell environment.
- Enter the Version Command: At the blinking cursor (the prompt), type the following command exactly as shown:
$PSVersionTable - Execute the Command: Press the Enter key on your keyboard.
- Read the Output: A list of properties will appear. Look for the row labeled PSVersion. The number listed to the right (e.g., 5.1.22621.1 or 7.4.1) is your current version.
Common Mistakes
- Case Sensitivity: While PowerShell is generally case-insensitive for many commands, using the exact casing
$PSVersionTableis the standard practice to ensure the variable is recognized correctly. - Typing the Dollar Sign: A common error is forgetting the
$symbol at the beginning. In PowerShell, the dollar sign indicates that you are calling a variable; without it, PowerShell will try to run a command that doesn't exist and return an error. - Confusing PowerShell with CMD: If you see
C:\Users\Name>and the$PSVersionTablecommand returns an error saying the term is not recognized, you are likely in the Command Prompt (CMD) rather than PowerShell. You must switch to PowerShell for this command to work.
Tips
- Quick Check for Scripts: If you are writing a script and need to ensure it only runs on a specific version, you can use the
#requires -version 7.0statement at the top of your script. - Alternative Command: If you prefer a shorter command, you can use
host. However,hostprovides information about the "host" application (the window you are using) rather than the underlying PowerShell engine version, which can occasionally be misleading. - Distinguishing Versions: If your version starts with a 5, you are using Windows PowerShell (the legacy version built into Windows). If it starts with a 6 or 7, you are using PowerShell Core/PowerShell (the modern, open-source version).
Troubleshooting
If the command does not work as expected, try these steps in order:
- Check the Application: Ensure the window header says "Windows PowerShell" or "PowerShell." If it says "Command Prompt," type
powershelland press Enter to enter the PowerShell environment, then try the command again. - Check for Typos: Ensure there are no spaces between the
$andPSVersionTable. - Restart the Console: If the console is frozen or not responding to input, close the window and reopen it.
- Verify Installation: If you cannot find PowerShell in your Start menu, it may have been disabled or removed. Check your Windows Features (via Control Panel) to ensure "Windows PowerShell" is enabled.
Frequently Asked Questions
Why do I have two different versions of PowerShell?
Windows comes with "Windows PowerShell" (version 5.1) by default for system compatibility. "PowerShell" (version 7+) is a separate, modern installation that can coexist with the older version to provide newer features and cross-platform support.
Can I check the version without opening the console?
Not easily. The most reliable way to see the active version is to run the command within the environment itself, as different versions can be installed on the same machine.
What does the "PSEdition" line in the table mean?
The PSEdition line tells you the engine type. "Desktop" refers to the version built for Windows, while "Core" refers to the cross-platform version designed to run on Windows, macOS, and Linux.
Is PowerShell 7 better than Windows PowerShell 5.1?
PowerShell 7 is generally faster and contains more updated commands and features. However, Windows PowerShell 5.1 remains the standard for many legacy Windows system administration tasks.
Will this command work on a Mac or Linux?
Yes, provided you have installed PowerShell (pwsh) on your system. Once you launch the pwsh shell, the $PSVersionTable command works identically to how it does on Windows.