Redirect 301 /ads.txt https://srv.adstxtmanager.com/19390/vmorecloud.com How To Get Windows Operating System Version Count Inventory Report From Domain Computers Mastodon
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
34views

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 14

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 15
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

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

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 17

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 18

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 19

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 20

    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 21

    Leave a Response