Windows OS Hub
  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux

 Windows OS Hub / PowerShell / Find Windows OS Versions and Builds in Active Directory

February 20, 2023

Find Windows OS Versions and Builds in Active Directory

Let’s look at several ways to inventory versions and builds of Windows OSs in an Active Directory domain (it is especially relevant for Windows 10). If you haven’t any tools to automatically get computer configurations, such as SCCM, GLPI with FusionInventory, or at least the Windows Server Update (WSUS) host (it also lets you get the Windows version on discovered computers), you can use a PowerShell script to find Windows versions/builds on domain computers.

On a standalone computer, you can get a Windows version and build number from the registry or with SystemInfo:

Get-ItemProperty 'HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion' | Select-Object ProductName, ReleaseID, CurrentBuild

How to find the Windows version and build from the PowerShell?

Get-ComputerInfo | select WindowsProductName, WindowsVersion, OsHardwareAbstractionLayer

To get a list of active computers in an Active Directory domain and Windows versions (builds) on them, you can use the Get-ADComputers cmdlet.

Remember to regularly disable and remove inactive computer accounts in your domain.

Make sure that the Active Directory Module for PowerShell is installed on your computer and run the command below:

Get-ADComputer -Filter {(Enabled -eq $True)} -Property * | Select-Object Name,OperatingSystem,OperatingSystemVersion

Get list of domain-computers with Operating System Versions and WIndows builds

To convert the build number of Windows 10 and 11 to a more convenient format (21H1, 21H2, etc.), you need to use an additional function.

function ConvertWindowsBuild{
[CmdletBinding()]
param(
[string] $OperatingSystem,
[string] $OperatingSystemVersion
)
if (($OperatingSystem -like '*Windows 10*') –or ($OperatingSystem -like 'Windows 11*')) {
$WinBuilds= @{
'10.0 (22621)' = "Windows 11 22H2"
'10.0 (19045)' = "Windows 10 22H2"
'10.0 (22000)' = "Windows 11 21H2"
'10.0 (19044)' = "Windows 10 21H2"
'10.0 (19043)' = "Windows 10 21H1"
'10.0 (19042)' = "Windows 10 20H2"
'10.0 (18362)' = "Windows 10 1903"
'10.0 (17763)' = "Windows 10 1809"
'10.0 (17134)' = "Windows 10 1803"
'10.0 (16299)' = "Windows 10 1709"
'10.0 (15063)' = "Windows 10 1703"
'10.0 (14393)' = "Windows 10 1607"
'10.0 (10586)' = "Windows 10 1511"
'10.0 (10240)' = "Windows 10 1507"
'10.0 (18898)' = 'Windows 10 Insider Preview'
}
$WinBuild= $WinBuilds[$OperatingSystemVersion]
}
else {$WinBuild = $OperatingSystem}
if ($WinBuild) {
$WinBuild
} else {
'Unknown'
}
}

Then, to get a list of Windows versions with hostnames, build numbers, IP addresses, and the computer’s last domain logon, run the following PowerShell script:

$Comps= Get-ADComputer -Filter {(Enabled -eq $True)} -properties *
$CompList = foreach ($Comp in $Comps) {
[PSCustomObject] @{
Name = $Comp.Name
IPv4Address = $Comp.IPv4Address
OperatingSystem = $Comp.OperatingSystem
Build = ConvertWindowsBuild -OperatingSystem $Comp.OperatingSystem -OperatingSystemVersion $Comp.OperatingSystemVersion
LastLogonDate = $Comp.LastLogonDate
}
}
$CompList | Out-GridView

You can display the output as an Out-GridView table or export the list of computers to a CSV file (Export-Csv -Path .\windows_version_report.csv -NoTypeInformation).

PowerShell script to generate a report of Windows 10 systems by build number in Active Directory

To display a summary statistics on a number of computers with different Windows versions and builds in your domain:

$CompList | Group-Object -Property Build | Format-Table -Property Name, Count

Finding Windows Versions in Active Directory

You can also query your computers remotely and get Windows versions on them using PowerShell Remoting. This method is slower, but it allows you to get Windows versions on computers in a workgroup environment (PSRemoting in a Workgroup). To get information from remote computers, you may use the Invoke-Command cmdlet:

Invoke-Command -ScriptBlock {Get-ItemProperty 'HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion' | Select-Object ProductName, ReleaseID, CurrentBuild} -ComputerName wsk-w12b21| Select-Object PSComputerName,ProductName, ReleaseID, CurrentBuild

You can get Windows versions on multiple computers according to the list in a TXT file:

Invoke-Command –ComputerName (Get-Content c:\ps\PC_list.txt) -ScriptBlock {Get-ItemProperty 'HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion' | Select-Object ProductName, ReleaseID, CurrentBuild}|Select-Object PSComputerName,ProductName, ReleaseID, CurrentBuild

Get Windows version/build on remote computer with PowerShe

You can use these Powershell scripts to get Windows versions and builds on domain computers, find computers with old (unsupported) Windows 10 builds, and update them (How to Update Windows 10 Build with Command-Line?)

0 comment
2
Facebook Twitter Google + Pinterest
Active DirectoryPowerShellWindows 10Windows 11Windows Server 2019
previous post
Migrating RDS Roles (Connection Broker, Web Access) to Another Server
next post
Enable SSH on VMware ESXi Host

Related Reading

Fix: Remote Desktop Licensing Mode is not Configured

August 24, 2023

Wi-Fi (Internet) Disconnects After Sleep or Hibernation on...

March 15, 2024

How to Install Remote Server Administration Tools (RSAT)...

March 17, 2024

How to Find the Source of Account Lockouts...

March 12, 2024

Managing Windows Firewall Rules with PowerShell

March 11, 2024

How to Delete Old User Profiles in Windows

March 15, 2024

Install and Manage Windows Updates with PowerShell (PSWindowsUpdate)

March 17, 2024

Start Menu or Taskbar Search Not Working in...

April 22, 2025

Leave a Comment Cancel Reply

join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Recent Posts

  • Map a Network Drive over SSH (SSHFS) in Windows

    May 13, 2025
  • Configure NTP Time Source for Active Directory Domain

    May 6, 2025
  • Cannot Install Network Adapter Drivers on Windows Server

    April 29, 2025
  • Change BIOS from Legacy to UEFI without Reinstalling Windows

    April 21, 2025
  • How to Prefer IPv4 over IPv6 in Windows Networks

    April 9, 2025
  • Load Drivers from WinPE or Recovery CMD

    March 26, 2025
  • How to Block Common (Weak) Passwords in Active Directory

    March 25, 2025
  • Fix: The referenced assembly could not be found error (0x80073701) on Windows

    March 17, 2025
  • Exclude a Specific User or Computer from Group Policy

    March 12, 2025
  • AD Domain Join: Computer Account Re-use Blocked

    March 11, 2025

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Configure Google Chrome Settings with Group Policy
  • Get-ADUser: Find Active Directory User Info with PowerShell
  • Allow Non-admin Users RDP Access to Windows Server
  • How to Find the Source of Account Lockouts in Active Directory
  • How to Disable or Enable USB Drives in Windows using Group Policy
  • Get-ADComputer: Find Computer Properties in Active Directory with PowerShell
  • Configuring Proxy Settings on Windows Using Group Policy Preferences
Footer Logo

@2014 - 2024 - Windows OS Hub. All about operating systems for sysadmins


Back To Top