How to find Windows OS version using Powershell?

Powershell can be used to fetch operating system version details on Windows computers. There are multiple methods to get the required details of the operating system, including the build number. We list the few Powershell commands that can be used to get system information of a local or remote computer.

Using systeminfo to fetch OS version on Windows computer

The simplest command to fetch detailed information of a Windows computer is to use the systeminfo command. The command is shared below for your ready reference:

systeminfo /fo csv | ConvertFrom-Csv | select OS, System, Hotfix* | Format-List

To use the command, we will follow the process below.

On your Windows 11 computer, launch Powershell. You can do so by using the ‘pwsh’ command in the command prompt or the search box. The screen capture below shows pwsh in the search box.

pwsh command

Once Powershell loads on the computer, use the systeminfo command to fetch OS version, build number and other details of the system in a short and concise format.

The command to use is:

systeminfo /fo csv | ConvertFrom-Csv | select OS, System, Hotfix* | Format-List

Once you type this command, the command output will contain all the system information as per the image below:

I find the systeminfo command as the best command to run on a local or remote computer to get all the information in one place. However, there are simpler Powershell directives that can provide the build number and Windows version information. WmiObject can be used to fetch system details as displayed hereunder.

Using WmiObject to find operating system details

We use a generic WMIObject to find operating system information on the computer. The command that we will use is:

(Get-WMIObject win32_operatingsystem)

The command output of this Powershell command is displayed below:

This WMIObject directive brings in the version of Windows and the build number. The serial number of the computer is also offered as part of the Powershell directive. You can qualify this Powershell directive with multiple filters to bring up the desired information.

(Get-WMIObject win32_operatingsystem) | Select Name

This command will display the name of the operating system in the Powershell window. In my case, it displayed:

Microsoft Windows 11 Home Insider Preview Single Language|C:\WINDOWS|\Device\Harddisk1\Partition3

(Get-WMIObject win32_operatingsystem) | Select OSArchitecture

This Powershell command confirms if your system is using a 32 bit or 64 bit architecture.

(Get-WMIObject win32_operatingsystem) | Select BuildNumber

This command only brings in the build number of the computer. In my case, it showed build number 25236.

Using CimInstance to find operating system information

Similar to the WMIObjective directive, we can use the CimInstance directive to pull the operating system information using Powershell.

The following command will fetch the operating system details and serial number of the computer:

(Get-CimInstance Win32_OperatingSystem)

The command output of the CimInstance command is displayed below:

You can qualify this command output by looking for specific information.

  • (Get-CimInstance Win32_OperatingSystem).version command will just output the version number.
  • (Get-CimInstance Win32_OperatingSystem).BuildNumber will output the build number.
  • (Get-CimInstance Win32_OperatingSystem).SerialNumber will output the serial number of the computer.

Summary

We have seen multiple ways to fetch operating system version, build number and OS details using different methods that include:

  • systeminfo
  • WMIObject directive
  • CimInstance directive

You could use any of these to fetch OS details on your computer using Powershell

Suggested Powershell Tutorials

You may like to read more content related to Powershell cmdlets, directives and tutorials:

How useful was this post?

Click on a star to rate it!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Rajesh Dhawan

Rajesh Dhawan is a technology professional who loves to blog about smart wearables, Cloud computing and Microsoft technologies. He loves to break complex problems into manageable chunks of meaningful information.