Retrieves information about the operating system version and architecture.
The Get-OSInfo function is a PowerShell script that queries both the Windows registry and the Win32_OperatingSystem class to gather comprehensive information about the operating system.
The function returns the following:
| Property | Description | Example Output |
|---|---|---|
| Release ID | The release ID of the operating system | 2004 |
| Display Version | The display version of the operating system | 20H2 |
| Name | The product name of the operating system | Windows 10 Pro |
| Type | Workstation or Server | Workstation |
| Numeric Version | The numeric version of the operating system | 10 |
| Edition ID | The edition ID of the operating system | Professional |
| Version | Object including major, minor, and build numbers | 10.0.19042.0 |
| Architecture | OS architecture (not processor architecture) | x64 |
Get-OSInfoThis example retrieves the OS version details of the current system and returns an object with properties as mentioned above.
Output from Windows 10 Pro
ReleaseId : 2004
DisplayVersion : 20H2
Name : Windows 10 Pro
Type : Workstation
NumericVersion : 10
EditionId : Professional
Version : 10.0.19042.0
Architecture : x64
Output from Server 2022 Datacenter
ReleaseId : 2009
DisplayVersion : 21H2
Name : Microsoft Windows Server 2022 Datacenter
Type : Server
NumericVersion : 2022
EditionId : Datacenter
Version : 10.0.20348.0
Architecture : x64
(Get-OSInfo).Version.MajorThis example retrieves the major version number of the operating system. The Get-OSInfo function returns an object with a Version property, which itself is an object containing Major, Minor, and Build properties. You can access these sub-properties using dot notation.
Output
10
$osDetails = Get-OSInfo
Write-Output "OS Name: $($osDetails.Name)"
Write-Output "OS Type: $($osDetails.Type)"
Write-Output "OS Architecture: $($osDetails.Architecture)"This example stores the result of Get-OSInfo in a variable and then accesses various properties to print details about the operating system.
Output
Name: Windows 10 Pro
Type: Workstation
Architecture: x64
- The function uses both registry values and CIM instances to gather information.
- It includes error handling to catch any issues that may arise during execution.
- The architecture details are specifically related to the OS, not the processor, and are represented as x32, x64, arm, or arm64.



My bad. I was looking at $registryValues.ProductName, which shows Sandbox as being "Windows 10 Enterprise" rather than 11. $osDetails.Caption seems to be getting the name right though.