Get List of Operating Systems

by Dec 23, 2015

If your boss needs a list of operating systems used by computers in your AD, this may be a good start:

#requires -Version 1 -Modules ActiveDirectory

$max = 100

$os = Get-ADComputer -Filter * -Properties OperatingSystem -ResultPageSize $max | 
Group-Object -Property OperatingSystem -NoElement | 
Select-object -ExpandProperty Name |
ForEach-Object { '"{0}"' -f $_ }

$list = $os -join ','
$list
# copy list to clipboard
$list | clip

This script gets all computer accounts from your AD and groups them by operating system, then produces a list from it. Make sure you play with PageSize because retrieving all computers in a large organization may take a long time.

Twitter This Tip! ReTweet this Tip!