Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

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

February 20, 2023 Active DirectoryPowerShellWindows 10Windows 11Windows Server 2019

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
previous post
Migrating RDS Roles (Connection Broker, Web Access) to Another Server
next post
Enable SSH on VMware ESXi Host

Related Reading

How to Connect VPN Before Windows Logon

November 14, 2023

Using WPAD (Web Proxy Auto-Discovery Protocol) on Windows

November 7, 2023

Send Emails with Microsoft Graph API and PowerShell

November 6, 2023

Zabbix: How to Get Data from PowerShell Scripts

October 27, 2023

Tracking Printer Usage with Windows Event Viewer Logs

October 19, 2023

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMWare
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • How to Connect VPN Before Windows Logon

    November 14, 2023
  • Removing Azure Arc Setup Feature on Windows Server 2022

    November 9, 2023
  • Using WPAD (Web Proxy Auto-Discovery Protocol) on Windows

    November 7, 2023
  • Send Emails with Microsoft Graph API and PowerShell

    November 6, 2023
  • Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023
  • Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023
  • PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 15, 2023
  • Reset Root Password in VMware ESXi

    October 12, 2023
  • How to Query and Change Teams User Presence Status with PowerShell

    October 8, 2023
  • How to Increase Size of Disk Partition in Ubuntu

    October 5, 2023

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 - 2023 - Windows OS Hub. All about operating systems for sysadmins


Back To Top