How to detect each Windows OS is used with powershell



As an IT administrator, one of the key tasks is to understand the operating system (OS) being used on all computers in the organization. This is important for managing the systems, troubleshooting, patching, and security. Fortunately, PowerShell can be used to quickly detect the OS version for each computer.

To view the OS version for each computer, the Get-WmiObject cmdlet can be used. This cmdlet allows for querying the Windows Management Instrumentation (WMI) objects on each computer. To use this cmdlet, the computer name must be specified. This can be done by entering multiple computer names or by providing a list of computer names from a text file.

Once the computer names are known, the Get-WmiObject cmdlet can be used. This cmdlet requires the Win32_OperatingSystem class to be specified. This class contains information about the OS, such as the name, version, serial number, and OS architecture. The following command can be used to view the OS version for each computer:

Get-WmiObject -Class Win32_OperatingSystem -ComputerName

The output will show the OS version for each computer. This can then be used to determine if the computers are running the correct OS version.

To further narrow down the OS version for each computer, the Win32_OperatingSystem class also provides additional information. This includes the release ID, build number, and product type. The release ID is used to distinguish between minor versions of the same OS. The build number is used to distinguish between patches and service packs. The product type is used to determine if the OS is a client or server edition. The following command can be used to view this additional information:

Get-WmiObject -Class Win32_OperatingSystem -ComputerName | Select-Object -Property ReleaseId, BuildNumber, ProductType

In addition to the WMI query, the Get-CimInstance cmdlet can also be used. This cmdlet is similar to the Get-WmiObject cmdlet, but uses the CIM (Common Information Model) objects. The CIM objects are more efficient than the WMI objects, so they can be used to get the OS version faster. The following command can be used to view the OS version using the Get-CimInstance cmdlet:

Get-CimInstance -ClassName Win32_OperatingSystem -ComputerName

Once the OS version is known, additional commands can be used to manage the computers, such as managing services, patching, and security. PowerShell can also be used to query the registry to determine the installed software, hardware, and other configuration settings.

Using PowerShell to detect each Windows OS version is an easy and efficient way for an IT administrator to manage the computers in their organization. It allows for quickly querying the OS version and additional information for each computer. This can be used to ensure that the computers are running the correct version and to manage services, patching, and security.

Inquire Now

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Find your next full or part-time role here

ScaleDesk can either help you find your next full time gig or a part time side gig where you can create extra income!

Onboard with us once
Skip HR screening and go to the final interview with with only your resume and a video interview you never have to redo
Get paid electronically every month for the hours you work
We will be your reference even if you work for us once

IT Teams: Use ScaleDesk to augment your team

Schedule Demo