Mastodon

latest posts

- Advertisement -
VMoreCloud
MicrosoftWindows Server 2022

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

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

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.

ParameterValue
Server OSWindows Server 2022
IP Address192.168.91.129
DNS Domainvmorecloud.com
FQDNserver.vmorecloud.com
RoleActive Directory Domain Controller
Tools UsedPowerShell, 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

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
How To Get Windows Operating System Version Count Inventory Report From Domain Computers
How To Get Windows Operating System Version Count Inventory Report From Domain Computers 16

Expected Output

Count Name
----- ----
2 Windows Server 2025 Datacenter Evaluation
1 Windows 11 Enterprise Evaluation

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
How To Get Windows Operating System Version Count Inventory Report From Domain Computers
How To Get Windows Operating System Version Count Inventory Report From Domain Computers 17
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

================================

Windows OS Inventory Report

Domain: vmorecloud.com

================================

Report paths

$ReportPath = “C:\Reports”
$CsvFile = “$ReportPath\OS_Inventory_Report.csv”
$SummaryPath = “$ReportPath\OS_Count_Summary.csv”
$HtmlFile = “$ReportPath\OS_Inventory_Report.html”

Create Reports folder if missing

if (!(Test-Path $ReportPath)) {
New-Item -ItemType Directory -Path $ReportPath | Out-Null
}

================================

Collect Computer Information

================================

$Computers = Get-ADComputer -Filter * -Properties OperatingSystem, OperatingSystemVersion,
LastLogonDate, IPv4Address, Description

================================

Detailed CSV Export

================================

$Computers | Select-Object @{N='ComputerName';E={$_.Name}},
@{N=’OperatingSystem’;E={$_.OperatingSystem}}, @{N='Version';E={$_.OperatingSystemVersion}},
@{N=’LastLogon’;E={$_.LastLogonDate}}, @{N='IPAddress';E={$_.IPv4Address}},
@{N=’Description’;E={$_.Description}} |
Sort-Object OperatingSystem, ComputerName |
Export-Csv -Path $CsvFile -NoTypeInformation

Write-Host “Detailed report exported to: $CsvFile” -ForegroundColor Green

================================

OS Summary Count

================================

$Summary = $Computers |
Group-Object OperatingSystem |
Select-Object @{N='OS';E={$_.Name}},
@{N=’Count’;E={$_.Count}}

Total computers

$Total = ($Summary | Measure-Object Count -Sum).Sum

Calculate percentage

$Summary = $Summary | ForEach-Object {
[PSCustomObject]@{
OS = $_.OS
Count = $_.Count
Percent = “{0:P1}” -f ($_.Count / $Total)
}
}

Export summary CSV

$Summary |
Sort-Object Count -Descending |
Export-Csv -Path $SummaryPath -NoTypeInformation

Write-Host “Summary exported to: $SummaryPath” -ForegroundColor Green

================================

Generate HTML Dashboard

================================

$TableRows = $Summary | ForEach-Object {
“$($_.OS)$($_.Count)$($_.Percent)”
}

$Html = @”



Windows OS Inventory – vmorecloud.com

Windows OS Inventory Report

Domain: vmorecloud.com

Generated: $(Get-Date)

Total Computers: $Total $($TableRows -join “`n”)

Operating SystemCountPercentage



“@

$Html | Out-File -FilePath $HtmlFile -Encoding UTF8

Write-Host "HTML Report generated: $HtmlFile" -ForegroundColor Green
Write-Host "`nAll reports saved in: $ReportPath" -ForegroundColor Cyan

How to Run the Script

Execute the script:

Output Files Created

The script will generate three reports:

📁 C:\Reports\OS_Inventory_Report.csv
➡ Detailed computer inventory

📁 C:\Reports\OS_Count_Summary.csv
➡ OS count summary

📁 C:\Reports\OS_Inventory_Report.html
➡ Professional dashboard report
 
How To Get Windows Operating System Version Count Inventory Report From Domain Computers
How To Get Windows Operating System Version Count Inventory Report From Domain Computers 18
How To Get Windows Operating System Version Count Inventory Report From Domain Computers
How To Get Windows Operating System Version Count Inventory Report From Domain Computers 19

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

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

In the left pane, navigate to your domain vmorecloud.com

Select the Computers container or relevant OU

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

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

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

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

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

Enter OperatingSystem as the field and filter as needed

iRecommendation 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
How To Get Windows Operating System Version Count Inventory Report From Domain Computers
How To Get Windows Operating System Version Count Inventory Report From Domain Computers 24

Windows OS Build Number Reference

Use this reference table to decode the OperatingSystemVersion field returned by Active Directory queries.

Operating SystemBuild NumberRelease DateSupport Status
Windows 11 23H210.0.22631Oct 2023Supported
Windows 11 22H210.0.22621Sep 2022Supported
Windows 11 21H210.0.22000Oct 2021Supported
Windows 10 22H210.0.19045Oct 2022Supported
Windows 10 21H210.0.19044Nov 2021Limited
Windows 10 190910.0.18363Nov 2019EOL
Windows Server 202210.0.20348Aug 2021Supported
Windows Server 201910.0.17763Oct 2018Supported
Windows Server 201610.0.14393Oct 2016Limited
Windows Server 2012 R26.3.9600Nov 2013EOL

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
How To Get Windows Operating System Version Count Inventory Report From Domain Computers
How To Get Windows Operating System Version Count Inventory Report From Domain Computers 25

Leave a Response

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
100% Free SEO Tools - Tool Kits PRO