Get all of your Windows 10 versions from AD
- ToddimusPrime
- Mar 11, 2022
- 1 min read
Active Directory has a field that shows you the Windows version of the computer object. But for some reason Mr. Gates has decided that build numbers are what should be in that field. Not something useful like 21H1 or whatever. Use this script to get a list of enabled Windows 10 computers in your domain, and it will then convert the build number into something better. If you're reading this in the future, just add in whatever new build numbers Mr. Ballmer has created to the 'switch' part of the script.
$computers = Get-ADComputer -Filter { enabled -eq $true -and OperatingSystem -like "Windows 10*" } -Properties OperatingSystemVersion
$list = @()
foreach ( $computer in $computers )
{
$result = switch ( $computer.OperatingSystemVersion )
{
"10.0 (10240)" {"1507"}
"10.0 (10586)" {"1511"}
"10.0 (14393)" {"1607"}
"10.0 (15063)" {"1703"}
"10.0 (16299)" {"1709"}
"10.0 (17134)" {"1803"}
"10.0 (17763)" {"1809"}
"10.0 (18362)" {"1903"}
"10.0 (18363)" {"1909"}
"10.0 (19041)" {"20H1"}
"10.0 (19042)" {"20H2"}
"10.0 (19043)" {"21H1"}
"10.0 (19044)" {"21H2"}
}
$compy = [PSCustomObject]@{
Name = $computer.Name
Version = $result
}
$list += $compy
}
$list | Export-Csv c:\scripts\OSVersions.csv -NoTypeInformation



Comments