How to get Windows version from command prompt or from PowerShell

Learn how to get windows version from command prompt or from powershell with practical examples, diagrams, and best practices. Covers windows, windows-10, windowsversion development techniques with...

How to Get Your Windows Version from the Command Prompt or PowerShell

Hero image for How to get Windows version from command prompt or from PowerShell

Learn various methods to quickly identify your Windows operating system version and build number using command-line tools like Command Prompt and PowerShell.

Knowing your exact Windows version and build number is crucial for troubleshooting, installing compatible software, or verifying system updates. While you can find this information through the graphical user interface (GUI), using the command line or PowerShell often provides a quicker and more scriptable way to retrieve these details. This article will guide you through several effective methods.

Using the Command Prompt (CMD)

The Command Prompt offers a few straightforward commands to get your Windows version. These methods are generally quick and don't require administrative privileges, making them accessible for most users.

ver

The 'ver' command provides a concise Windows version.

The ver command is the simplest way to get a basic version string. For more detailed information, including the build number, the systeminfo command is more comprehensive.

systeminfo | findstr /B /C:"OS Name" /C:"OS Version"

Using 'systeminfo' to filter for OS Name and Version.

Using PowerShell

PowerShell provides more robust and object-oriented ways to query system information. This is particularly useful for scripting and automation, as the output can be easily manipulated.

$PSVersionTable.OS

Retrieving OS information directly from the $PSVersionTable variable.

The $PSVersionTable.OS property gives you a quick summary of the operating system. For more detailed information, including the full build number and service pack details, you can query the Windows Management Instrumentation (WMI) using Get-CimInstance or Get-WmiObject.

(Get-CimInstance Win32_OperatingSystem).Caption
(Get-CimInstance Win32_OperatingSystem).Version
(Get-CimInstance Win32_OperatingSystem).BuildNumber

Querying Win32_OperatingSystem class for detailed version information.

flowchart TD
    A[Start] --> B{"Need Windows Version?"}
    B -->|Yes| C{CMD or PowerShell?}
    C -->|CMD| D[Run 'ver' or 'systeminfo']
    C -->|PowerShell| E[Run '$PSVersionTable.OS' or 'Get-CimInstance']
    D --> F[Get Basic/Detailed Version]
    E --> G[Get Object-Oriented Version]
    F --> H[End]
    G --> H[End]
    B -->|No| H[End]

Decision flow for retrieving Windows version.

Understanding the Version Numbers

Windows version numbers can sometimes be confusing. Here's a quick breakdown of what you might see:

  • Major.Minor.Build.Revision: This is the standard format. For example, 10.0.19045.3693.
    • 10.0: Indicates Windows 10 or Windows 11 (they share the same major/minor version).
    • 19045: This is the OS Build number, which corresponds to a specific feature update (e.g., 22H2).
    • 3693: This is the Revision number, indicating cumulative updates applied after the feature update.

Knowing these components helps in identifying the exact state of your Windows installation.

Practical Application

These commands are not just for curiosity. They are invaluable for:

  • Software Compatibility: Ensuring an application supports your specific Windows version.
  • Driver Updates: Verifying if a driver is suitable for your OS build.
  • Troubleshooting: Providing precise system information to support personnel.
  • Scripting: Automating checks for system requirements before deploying software or configurations.

By mastering these simple command-line and PowerShell techniques, you can efficiently retrieve critical Windows version information whenever needed, enhancing your system administration and troubleshooting capabilities.