Config Server Firewall

PowerShell Command to Get Windows Version

In Windows PowerShell, Get-ComputerInfo is the command to gather information about your computer. When you run the Get-ComputerInfo without any parameter, it shows lots of information about the local computer, including Hardware, Operating System , and Bios.

Get-ComputerInfo

To retrieve a specific piece of information, use the -Property option. For example, to get the Windows version, run the Get-ComputerInfo command as follows:

Get-ComputerInfo -Property OsName

The following was the output when I executed the above command on my Windows Desktop:

Get Windows version in PowerShell
Get Windows Version

It shows I am running Microsoft Windows 11 Pro on my PC.

To get the Windows version without the header, run the Get-ComputerInfo command as follows:

(Get-ComputerInfo).OsName

In the following example, we check the Windows Edition:

Get-ComputerInfo -Property WindowsEditionId

We can retrieve multiple pieces of information at once by providing a comma-separated list of properties to the -Property parameter:

Get-ComputerInfo -Property OsName, WindowsEditionId, CsName, CsProcessors, OsInstallDate

In the following example, we gather every bit of information about the operating system using the wildcard search:

Get-ComputerInfo -Property os*

The above command shows all properties related to the operating system running on the local computer.

OS Information

Alternatively, we can also check the Windows version using the Get-CimInstance command:

Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object Caption

And that is how we get the Windows version in PowerShell using the Get-ComputerInfo cmdlet.