This PowerShell script retrieves and displays the current Windows operating system name and version, including the major, minor, build, and revision numbers. It also lists all installed updates, sorted by installation date, with details such as the hotfix ID, description, and when each update was applied.
Click to view script…
# Get OS name
$os = Get-CimInstance -ClassName Win32_OperatingSystem
$osName = $os.Caption
# Get OS version
$osVersion = [System.Environment]::OSVersion.Version
# Display OS name and version
Write-Output "Operating System: $osName"
Write-Output "Version: $($osVersion.Major).$($osVersion.Minor).$($osVersion.Build).$($osVersion.Revision)"
# Get and display installed updates
Write-Output "Installed Updates:"
Get-HotFix | Sort-Object InstalledOn | Format-Table HotFixID, Description, InstalledOn