PowerShell – get windows 10 versions

Below script lists all Windows 10 versions that are installed on computers in Active Directory:

$win10 = get-adcomputer -filter 'OperatingSystem -like "Windows 10*"' -prop *
$win10count = ($win10 | Sort OperatingSystemVersion).count
$subject = "All Win 10 systems $win10count"
$win10_versions = $win10 | Sort OperatingSystemVersion | Select OperatingSystemVersion -unique

$result = @()
foreach ($ver in $win10_versions) {

$version = $ver.OperatingSystemVersion
$count = ($win10 | where OperatingSystemVersion -like $ver.OperatingSystemVersion | select OperatingSystemVersion | measure ).count
$result += New-Object psobject -Property @{
Win10_version = $version
Count = $Count
}
}

Send-MailMessage -From email@address.com -To email@address.com -subject $Subject -Body ($result | out-string) -smtpServer MAIL_SERVER -port 25

Example output:
.\get-Windows10_versions.ps1

Win10_version Count
------------- -----
10.0 (10240)      1
10.0 (10586)      9
10.0 (14393)     14
10.0 (15063)      4
10.0 (16299)     23
10.0 (17134)     18
10.0 (17763)     21
10.0 (18362)     35
10.0 (18363)    140
10.0 (19041)      1

Leave a Reply

Your email address will not be published. Required fields are marked *

one + five =

This site uses Akismet to reduce spam. Learn how your comment data is processed.