⚡ PowerShell 5.1+
Get Operating System Info Report
Queries Win32_OperatingSystem via WMI and reports Operating System Info in a formatted table, with an optional CSV export.
Get-OperatingSystemReport.ps1
<#
.SYNOPSIS
Reports Operating System Info on this computer via WMI (Win32_OperatingSystem).
.DESCRIPTION
Queries Win32_OperatingSystem and displays Caption, Version, OSArchitecture, LastBootUpTime, FreePhysicalMemory for each item found.
Use -ExportPath to also save the results to a CSV file.
.PARAMETER ExportPath
Optional path to a .csv file to write the results to.
.EXAMPLE
.\Get-OperatingSystemReport.ps1
.EXAMPLE
.\Get-OperatingSystemReport.ps1 -ExportPath C:\Reports\operatingsystem.csv
#>
[CmdletBinding()]
param(
[string]$ExportPath
)
$items = Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object Caption, Version, OSArchitecture, LastBootUpTime, FreePhysicalMemory
if (-not $items) {
Write-Host "No Operating System Info found." -ForegroundColor Yellow
return
}
$items | Format-Table -AutoSize
if ($ExportPath) {
$items | Export-Csv -Path $ExportPath -NoTypeInformation -Encoding UTF8
Write-Host "`nExported to $ExportPath" -ForegroundColor Cyan
}