PowerShell offers a easy and environment friendly option to get the Home windows model data you want. On this article, we’ll discover the best way to use PowerShell To Get Home windows model of your Home windows working system, and the best way to interpret the outcomes.
Utilizing the PowerShell To Get Home windows Model
One option to get solely the Home windows model data is to make use of the Choose-String cmdlet with the -Sample parameter. This cmdlet searches the output of the systeminfo command for a selected string sample and returns the matching strains.
For instance, to retrieve the Home windows model data from the output of the systeminfo command, you should use the next command:
systeminfo | Choose-String "OS Identify", "OS Model"
This command pipes the output of the systeminfo command to the Choose-String cmdlet, which searches for the string patterns “OS Identify” and “OS Model” within the output. The result’s a listing of strains containing the Home windows model data.
Selecting Particular Properties to Get Your Home windows Model
In PowerShell, you should use the systeminfo command to retrieve detailed details about your system, together with the Home windows model. Nevertheless, the command generates numerous output, and chances are you’ll solely have an interest within the Home windows model data.
To pick particular properties and retrieve solely the Home windows model data, you should use the Choose-String and Choose-Object cmdlets. The Choose-String cmdlet searches for a selected string within the output, and the Choose-Object cmdlet selects solely the required properties.
Right here’s an instance of the best way to use these cmdlets to retrieve the Home windows model data:
systeminfo | Choose-String "OS Identify", "OS Model" | Choose-Object -ExpandProperty Line
This command first runs the systeminfo command to generate the system data output. The Choose-String cmdlet is then used to seek for the strings “OS Identify” and “OS Model” within the output. The output of the Choose-String cmdlet is piped to the Choose-Object cmdlet, which selects the Line property of every matching object.
The ensuing output needs to be just like the next:
OS Identify: Microsoft Home windows 11 Dwelling Single Language
OS Model: 10.0.22621 N/A Construct 22621
BIOS Model: American Megatrends Worldwide, LLC. FX516PR.327, 20-08-2021
By deciding on solely the mandatory properties, you will get the Home windows model data in a extra concise and readable format.
Getting your Home windows Model with the System.Surroundings Class
To retrieve the Home windows model data particularly, you’ll be able to entry the OSVersion
property of the $PSVersionTable
variable. This property incorporates a System.Model
object that features the most important and minor model numbers, the construct quantity, and the revision variety of the working system.
Right here’s an instance PowerShell command that demonstrates the best way to retrieve the Home windows model utilizing the System.Surroundings
class:
[Environment]::OSVersion.Model
This command returns the model of the present working system in a four-part quantity format, akin to 10.0.19042.985
for Home windows 10 model 21H1.
You can even use the Get-CimInstance
cmdlet to retrieve details about the working system, together with the model quantity. Right here’s an instance PowerShell command that demonstrates the best way to use Get-CimInstance
to retrieve the Home windows model:
Get-CimInstance Win32_OperatingSystem | Choose-Object Caption,Model
This command returns the identify and model variety of the working system, akin to Microsoft Home windows 10 Professional
and 10.0.19042
.
Utilizing the System.Surroundings
class or the Get-CimInstance
cmdlet can present a easy option to retrieve the Home windows model in PowerShell.
Utilizing the Particular Property to Get the Home windows Model
When working with PowerShell, chances are you’ll wish to retrieve particular details about the Home windows model put in in your machine. A technique to do that is by digging up a selected property that incorporates the Home windows model knowledge.
To do that, you should use the Get-WmiObject cmdlet to question the Win32_OperatingSystem class, which offers details about the working system on the pc. This class features a property referred to as “Caption” that incorporates the identify of the working system, together with the model quantity.
Right here’s an instance command to retrieve the Home windows model utilizing the Get-WmiObject cmdlet:
Get-WmiObject -Class Win32_OperatingSystem | Choose-Object Caption
This command retrieves the Win32_OperatingSystem class and pipes it to the Choose-Object
cmdlet, which selects the “Caption” property. This property incorporates the identify of the working system, together with the model quantity.
Checking the Present Home windows Model
Querying for the present Home windows model is a standard process for system directors, builders, and energy customers alike. Fortuitously, PowerShell offers a number of methods to get this data rapidly and simply.
One method is to make use of the Get-ItemProperty cmdlet to retrieve details about the working system’s model. This cmdlet can be utilized to question the registry for particular values, together with the model of Home windows presently put in on the system.
For instance, to retrieve the present Home windows model utilizing Get-ItemProperty, you’ll be able to run the next command:
Get-ItemProperty 'HKLM:SOFTWAREMicrosoftWindows NTCurrentVersion' | Choose-Object ProductName, CurrentVersion
This command retrieves the product identify and present model of Home windows from the CurrentVersion key within the Home windows registry. The output will look one thing like this:
ProductName CurrentVersion
———– ————–
Home windows 10 Dwelling Single Language 6.3
One other method is to make use of the built-in $PSVersionTable variable. This variable incorporates details about the present PowerShell model, in addition to the model of Home windows that PowerShell is operating on.
To retrieve the Home windows model utilizing $PSVersionTable, you’ll be able to run the next command:
$PSVersionTable.OSVersion
This may return the present Home windows model quantity, akin to “10.0.19041.928”.
In conclusion, PowerShell provides a number of methods to retrieve the Home windows model.
Utilizing the SystemInfo command or the System.Surroundings class, together with deciding on particular properties or querying for the present model, can all make it easier to acquire the Home windows model data rapidly and simply.
Whether or not you’re a system administrator or a PowerShell consumer, understanding the best way to retrieve the Home windows model generally is a helpful ability to have in your toolset.