🧬 WQL / PowerShell

Win32_OperatingSystem: Operating System Info (WQL)

A minimal WQL reference query against Win32_OperatingSystem — the raw SELECT statement plus a one-line runner, useful for learning WMI Query Language independent of any host language.

By WindowsScripting.com · 967 B
OperatingSystemQuery.ps1
<#
.SYNOPSIS
    WQL reference: Operating System Info (Win32_OperatingSystem).

.DESCRIPTION
    A minimal example of querying Win32_OperatingSystem with a raw WQL SELECT
    statement via Get-CimInstance -Query — useful as a WMI Query
    Language reference, independent of any particular scripting
    language's WMI binding.

    The same query string works with Get-WmiObject -Query (older
    PowerShell), GetObject("winmgmts:...").ExecQuery(...) in VBScript
    or JScript, and ManagementObjectSearcher in C# — only the syntax
    around the query changes, not the WQL itself.

.EXAMPLE
    .\OperatingSystemQuery.ps1
#>

[CmdletBinding()]
param()

$wqlQuery = "SELECT Caption, Version, OSArchitecture, LastBootUpTime, FreePhysicalMemory FROM Win32_OperatingSystem"

Write-Host "WQL: $wqlQuery" -ForegroundColor DarkGray
Get-CimInstance -Query $wqlQuery | Format-Table -Property Caption, Version, OSArchitecture, LastBootUpTime, FreePhysicalMemory -AutoSize