# Getting Windows 10 build version from Active Directory

Today I saw an article on how to get Windows Version Report from Active Directory and thought that this is a cool idea. Something handy for migration scenarios or information on how up to date is your infrastructure. Since there are many ways to do the same thing I decided to tackle this myself and further include it into PSWinDocumentation.AD project. By default Active Directory stores Operating System and Operating System Version but it doesn’t really show versions one may expect.

blog

14 Jun 2019 en

![Getting Windows 10 build version from Active Directory](/wp-content/uploads/2019/06/img_5d03b4c46f7e1.png)

[View images (2)](#pf-content-image-1-0)

Today I saw an article on how to get **Windows Version Report from Active Directory **and thought that this is a cool idea. Something handy for migration scenarios or information on how up to date is your infrastructure. Since there are many ways to do the same thing I decided to tackle this myself and further include it into **[PSWinDocumentation.AD](https://github.com/EvotecIT/PSWinDocumentation.AD) **project. By default** Active Directory** stores **Operating System** and **Operating System Version** but it doesn't really show versions one may expect.

[!\[Active Directory computer properties showing raw Operating System and Operating System Version values for Windows 10.\](/wp-content/uploads/2019/06/img_5d03b143c6668.png)](/wp-content/uploads/2019/06/img_5d03b143c6668.png)

Sure it gives us information what system it is but version number is far from being anything** Microsoft marketing** department uses. So how one can do it? Well, as I've learned recently – **[there's only one way to do it – via hashtables](https://evotec.xyz/how-i-didnt-know-how-powerful-and-fast-hashtables-are/)**! It has to be fast and furious. While doing **foreach**, lots of **if/else** options we will get the same results for bigger domains it will take time.

### 💡 Getting Windows 10 Build Version from Active Directory

For the purpose of easy asking for Windows 10 version, I've created a simple function, that I will reuse doing **foreach** scenario.

```powershell
function ConvertTo-OperatingSystem {
    [CmdletBinding()]
    param(
        [string] $OperatingSystem,
        [string] $OperatingSystemVersion
    )

    if ($OperatingSystem -like 'Windows 10*') {
        $Systems = @{
            '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'
        }
        $System = $Systems[$OperatingSystemVersion]
    } elseif ($OperatingSystem -notlike 'Windows 10*') {
        $System = $OperatingSystem
    }
    if ($System) {
        $System
    } else {
        'Unknown'
    }
}
```

I've filled in some versions to use in my example, but surely it needs some updating to cover a whole range of systems you may have in your own **Active Directory**.

```powershell
$Computers = Get-ADComputer -Filter * -properties Name, OperatingSystem, OperatingSystemVersion, LastLogonDate, whenCreated
$ComputerList = foreach ($_ in $Computers) {
    [PSCustomObject] @{
        Name                   = $_.Name
        OperatingSystem        = $_.OperatingSystem
        OperatingSystemVersion = $_.OperatingSystemVersion
        System                 = ConvertTo-OperatingSystem -OperatingSystem $_.OperatingSystem -OperatingSystemVersion $_.OperatingSystemVersion
        LastLogonDate          = $_.LastLogonDate
        WhenCreated            = $_.WhenCreated
    }
}
$ComputerList | Group-Object -Property System | Format-Table -Property Name, Count
$ComputerList | Format-Table -AutoSize
```

[!\[PowerShell output grouping Active Directory computers by mapped Windows 10 build version and listing full details.\](/wp-content/uploads/2019/06/img_5d03b4c46f7e1.png)](/wp-content/uploads/2019/06/img_5d03b4c46f7e1.png)

And voila! We have two ways to display our systems. First, we used **Group-Object** to provide a count of systems, other one gave us a full list with an additional column called System that has data you need. Now I need to make sure it's integrated into **[PSWinDocumentation.AD](https://github.com/EvotecIT/PSWinDocumentation.AD)** so that next time I need it, it's there, waiting for me.

## Related Projects

Projects that align with this post's tags, categories, and content.

[All projects](/projects/)

Matching projects...

[Back to Blog](/blog)

## Related posts

- [Mastering Active Directory Hygiene: Automating Stale Computer Cleanup with CleanupMonster](/blog/mastering-active-directory-hygiene-automating-stale-computer-cleanup-with-cleanupmonster/)
- [Active Directory Replication Summary to your Email or Microsoft Teams](/blog/active-directory-replication-summary-to-your-email/)
- [Report Active Directory Accounts that are Synchronized with Azure AD](/blog/report-active-directory-accounts-that-are-synchronized-with-azure-ad/)

<!-- PowerForge markdown artifact sha256:883AA1141F18B467535BD0A5DFFEF86D562105E4E324EA5DD40D38C23D0A4996 -->
