How To Get Windows Operating System Version Count Inventory Report From Domain Computers

In enterprise environments, keeping track of the operating system versions deployed across domain-joined machines is a fundamental IT hygiene and security requirement. Whether you are preparing for patch management, compliance auditing, hardware refresh planning, or end-of-life remediation, knowing exactly how many machines run each Windows version is essential.
This lab tutorial walks you through multiple methods to generate a Windows OS Version Count Inventory Report using your Windows Server 2022 domain controller — from built-in PowerShell cmdlets to Active Directory queries and CSV exports.
| Parameter | Value |
| Server OS | Windows Server 2022 |
| IP Address | 192.168.91.129 |
| DNS Domain | vmorecloud.com |
| FQDN | server.vmorecloud.com |
| Role | Active Directory Domain Controller |
| Tools Used | PowerShell, Active Directory Module, RSAT |
Prerequisites
1. Active Directory Domain Services (AD DS)
Your Windows Server 2022 must be configured as an Active Directory Domain Controller with computers joined to the vmorecloud.com domain.
2. PowerShell Active Directory Module
The Active Directory PowerShell module must be installed. It is part of the Remote Server Administration Tools (RSAT). Verify with the command below:
# Check if AD module is available
Get-Module -Name ActiveDirectory -ListAvailable
If not installed, run the following on Windows Server 2022:
# Install RSAT Active Directory Tools
Install-WindowsFeature -Name RSAT-AD-PowerShell
Permissions Required
- Domain Admin or equivalent account
- Read access to Active Directory computer objects
- PowerShell running as Administrator
Note All commands in this tutorial should be executed on the Domain Controller (server.vmorecloud.com) or a machine with the AD PowerShell module and appropriate permissions.
Method 1: Quick Count with Get-ADComputer
The fastest way to get an OS version count is to query Active Directory directly using Get-ADComputer and group the results by OperatingSystem.
Step 1 — Open PowerShell as Administrator
On your domain controller server.vmorecloud.com, right-click the Start Menu and select Windows PowerShell (Admin) or Terminal (Admin).
Step 2 — Import the Active Directory Module
Import-Module ActiveDirectory
Step 3 — Run the Basic OS Count Query
# Get all domain computers and group by OS
Get-ADComputer -Filter * `
-Properties OperatingSystem, OperatingSystemVersion `
| Group-Object -Property OperatingSystem `
| Select-Object Count, Name `
| Sort-Object Count -Descending

Expected Output
Count Name
----- ----
2 Windows Server 2025 Datacenter Evaluation
1 Windows 11 Enterprise Evaluation
Tip — Spot Outdated OS Versions Any Windows 7, Windows XP, or Windows Server 2008 machines appearing in this output should be flagged for immediate remediation as they are end-of-life and no longer receive security updates.
Method 2: Detailed Inventory with Version Numbers
This method gives you granular detail including the exact build number alongside the OS name, which is critical for patch compliance.
# Detailed OS inventory including build version
Get-ADComputer -Filter * -Properties `
Name,
OperatingSystem,
OperatingSystemVersion,
OperatingSystemServicePack,LastLogonDate,
IPv4Address `
| Select-Object `
Name,
OperatingSystem,
OperatingSystemVersion,
LastLogonDate,
IPv4Address `
| Sort-Object OperatingSystem, OperatingSystemVersion `
| Format-Table -AutoSize

Count Name
----- ----
2 Windows Server 2025 Datacenter Evaluation
1 Windows 11 Enterprise Evaluation
Method 3: Export to CSV for Reporting
Exporting to CSV allows you to open the data in Excel or import it into reporting tools for management dashboards.
Export Full Inventory to CSV
# Export Windows OS inventory to CSV
$OutputPath = ‘C:\Reports\OS_Inventory_Report.csv’
# Create Reports directory if it doesn’t exist
if (-not (Test-Path ‘C:\Reports’)) {
New-Item -Path ‘C:\Reports’ -ItemType Directory | Out-Null
}
Get-ADComputer -Filter * -Properties `
OperatingSystem, OperatingSystemVersion, `
LastLogonDate, IPv4Address, Description `
| Select-Object `
@{N=’ComputerName’;E={$_.Name}}, `
@{N=’OS’;E={$_.OperatingSystem}}, `
@{N=’Version’;E={$_.OperatingSystemVersion}}, `
@{N=’LastLogon’;E={$_.LastLogonDate}}, `
@{N=’IPAddress’;E={$_.IPv4Address}}, `
@{N=’Description’;E={$_.Description}} `
| Sort-Object OS, ComputerName `
| Export-Csv -Path $OutputPath -NoTypeInformation
Write-Host “Report exported to: $OutputPath” -ForegroundColor Green
Export Summary Count Table
# Export just the OS count summary
$SummaryPath = 'C:\Reports\OS_Count_Summary.csv'
Get-ADComputer -Filter * -Properties OperatingSystem `
| Group-Object -Property OperatingSystem `
| Select-Object `
@{N='OperatingSystem';E={$_.Name}}, `
@{N='ComputerCount';E={$_.Count}} `
| Sort-Object ComputerCount -Descending `
| Export-Csv -Path $SummaryPath -NoTypeInformation
Write-Host "Summary exported to: $SummaryPath" -ForegroundColor Green
@{N='Description';E={$_.Description}} |
Sort-Object OperatingSystem, ComputerName |
Export-Csv -Path $CsvFile -NoTypeInformation
Write-Host "CSV Exported: $CsvFile" -ForegroundColor Green
# === HTML REPORT ===
$TableRows = $Summary | ForEach-Object {
"<tr><td>$($_.OS)</td><td>$($_.Count)</td><td>$($_.Percent)</td></tr>"
} | Out-String
$Html = @"
<!DOCTYPE html><html><head>
<title>OS Inventory - vmorecloud.com</title>
<style>body{font-family:Arial;} table{border-collapse:collapse;width:100%}
th{background:#1F3864;color:#fff;padding:8px;}td{padding:8px;border:1px solid #ccc;}</style>
</head><body>
<h1>Windows OS Inventory - vmorecloud.com</h1>
<p>Generated: $(Get-Date) | Total Computers: $Total</p>
<table><tr><th>Operating System</th><th>Count</th><th>Percentage</th></tr>
$TableRows</table></body></html>
"@
$Html | Out-File -FilePath $HtmlFile -Encoding UTF8
Write-Host "HTML Report: $HtmlFile" -ForegroundColor Green
Write-Host "`nDone! Reports saved to $ReportPath" -ForegroundColor Cyan
How to Run the Script
Execute the script:
Save the script to C:\Scripts\Get-OSInventory.ps1 on your server
Open PowerShell as Administrator
# Basic run (active computers only)
.\Get-OSInventory.ps1
# Include disabled computers
.\Get-OSInventory.ps1 -IncludeDisabled
# Custom output path
.\Get-OSInventory.ps1 -ReportPath 'D:\IT-Reports'
Method 5: Using Active Directory Users & Computers (GUI)
For administrators who prefer a GUI approach, Active Directory Users and Computers provides a basic view, though PowerShell is recommended for accurate counts.
Steps
Open Server Manager on server.vmorecloud.com
Click Tools → Active Directory Users and Computers

In the left pane, navigate to your domain vmorecloud.com
Select the Computers container or relevant OU

Right-click any column header in the right pane → select OperatingSystem
You can now see the OS column — click the column header to sort by OS
To get counts, use Find/Filter:
Right-click on Computers → Find

In the Find box, select Computers and use the Advanced tab

Enter OperatingSystem as the field and filter as needed
| i | Recommendation The GUI method is good for quick visual browsing but does not provide accurate counts or CSV export. Always use PowerShell (Methods 1-4) for inventory reporting and compliance documentation. |
Method 6: Remote Query Using Invoke-Command
If you want to retrieve live OS data directly from each computer (rather than from AD attributes which may be stale), use PowerShell remoting.
Prerequisites for Remoting
- WinRM must be enabled on target computers
- Firewall must allow PowerShell remoting (port 5985)
- Domain Admin credentials required
Enable WinRM via Group Policy (Recommended)
# Run on Domain Controller to enable WinRM domain-wide via GPO
# (Or use Group Policy: Computer Config > Windows Settings >
# Security Settings > Windows Firewall > Allow WinRM)
# Enable WinRM locally first
Enable-PSRemoting -Force
Remote Live OS Query
# Get live OS info from all domain computers
$Computers = Get-ADComputer -Filter 'Enabled -eq $true' |
Select-Object -ExpandProperty Name
$Results = Invoke-Command -ComputerName $Computers `
-ErrorAction SilentlyContinue `
-ScriptBlock {
$OS = Get-CimInstance Win32_OperatingSystem
[PSCustomObject]@{
ComputerName = $env:COMPUTERNAME
OS = $OS.Caption
Build = $OS.BuildNumber
Architecture = $OS.OSArchitecture
LastBoot = $OS.LastBootUpTime
}
}
# Show count summary
$Results | Group-Object OS |
Select-Object @{N='OS';E={$_.Name}}, Count |
Sort-Object Count -Descending |
Format-Table -AutoSize

Windows OS Build Number Reference
Use this reference table to decode the OperatingSystemVersion field returned by Active Directory queries.
| Operating System | Build Number | Release Date | Support Status |
| Windows 11 23H2 | 10.0.22631 | Oct 2023 | Supported |
| Windows 11 22H2 | 10.0.22621 | Sep 2022 | Supported |
| Windows 11 21H2 | 10.0.22000 | Oct 2021 | Supported |
| Windows 10 22H2 | 10.0.19045 | Oct 2022 | Supported |
| Windows 10 21H2 | 10.0.19044 | Nov 2021 | Limited |
| Windows 10 1909 | 10.0.18363 | Nov 2019 | EOL |
| Windows Server 2022 | 10.0.20348 | Aug 2021 | Supported |
| Windows Server 2019 | 10.0.17763 | Oct 2018 | Supported |
| Windows Server 2016 | 10.0.14393 | Oct 2016 | Limited |
| Windows Server 2012 R2 | 6.3.9600 | Nov 2013 | EOL |
Scheduling Automated Reports
Run the inventory script on a schedule using Windows Task Scheduler so your reports stay current without manual intervention.
Create a Scheduled Task via PowerShell
# Schedule weekly OS inventory report
$Action = New-ScheduledTaskAction `
-Execute 'powershell.exe' `
-Argument '-NonInteractive -ExecutionPolicy Bypass -File C:\Scripts\Get-OSInventory.ps1'
$Trigger = New-ScheduledTaskTrigger `
-Weekly -DaysOfWeek Monday -At '06:00AM'
$Settings = New-ScheduledTaskSettingsSet `
-ExecutionTimeLimit (New-TimeSpan -Hours 1) `
-MultipleInstances IgnoreNew
Register-ScheduledTask `
-TaskName 'Weekly-OS-Inventory' `
-Action $Action `
-Trigger $Trigger `
-Settings $Settings `
-RunLevel Highest `
-User 'vmorecloud\Administrator' `
-Description 'Weekly Windows OS Inventory for vmorecloud.com'
Write-Host 'Scheduled task created successfully.' -ForegroundColor Green








