Find OS Version with 5 Different Methods in Windows PowerShell

Find OS Version with Windows Powershell Techhyme

Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language. It was first released in 2006 and it is built on top of the .NET framework.

PowerShell allows system administrators to automate tasks, manage and control Windows-based systems and perform administrative tasks in a more efficient and consistent manner. It is also used for managing and automating various Microsoft products like Exchange Server, SharePoint Server, and Skype for Business.

To retrieve the version number of the operating system in PowerShell, you can use the below methods:

Method 1 – The version of OS can be determined by running the following command in a PowerShell prompt:

Command: .\\systeminfo

This will return the version number of PowerShell installed on the system, such as Major.Minor. Build. Revision.

Windows Powershell Version Ways Techhyme

Method 2 – If you only want specific property values, the Get-ComputerInfo command is one of the quickest methods of getting specific system information, like your Windows version. The Get-ComputerInfo cmdlet in PowerShell is used to retrieve information about the computer and its configuration.

By using the Select-Object cmdlet with the WindowsProductName, WindowsVersion, and OsHardwareAbstractionLayerVersion properties, you can display specific information about the operating system.

Command: Get-ComputerInfo | Select-Object WindowsProductName, WindowsVersion, OsHardwareAbstractionLayerVersion

Windows Powershell Version Ways Techhyme

Method 3 – Another way to get the Windows version is through the System.Environment class. This class provides access to system information, such as the OS version, username, and other environment variables.

The [System.Environment]::OSVersion.Version expression in PowerShell is used to retrieve the version of the operating system that the script is running on. This expression returns a Version object that contains information about the major, minor, build, and revision numbers of the operating system.

Command: [System.Environment]::OSVersion.Version

Windows Powershell Version Ways Techhyme

Method 4 – PowerShell cmdlets provide a handful of information about your system. But if you only plan to get your Windows version, the Get-ItemProperty cmdlet is another option. This cmdlet command lets you access the registry and get various properties from it.

Command: (Get-ItemProperty “HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion”).ReleaseId

The ReleaseId property contains the version number of the operating system.

Windows Powershell Version Ways Techhyme

Method 5 – The Get-CimInstance cmdlet is another way to get your Windows version by querying Windows Management Instrumentation (WMI) objects. Doing so lets you access various properties from your system hardware.

Command: (Get-CimInstance Win32_OperatingSystem).version

This will return the version number of the operating system, such as 10.0.22621.

Windows Powershell Version Ways Techhyme

Conclusion –

In conclusion, there are several ways to retrieve the version number of the operating system in PowerShell. Each method provides a different approach to retrieve information about the operating system, and it depends on the specific requirements and the intended use of the script to determine which method is the best fit.

You may also like:

Related Posts

Leave a Reply