Sometimes we need a list of data values and their frequency. Other times, we need a unique listing of data values. Under Unix, ‘sort -u’ gives a unique listing of values from STDIN, and ‘sort | uniq -c’ gives a listing of unique values and their frequencies. This is great if we’re processing them as strings, but PowerShell gives us a stream of objects in the pipeline, so we can better leverage that:
Get-ServerFarmInventory | Group-Object -Property SKU | select count, name
Assuming ‘Get-ServerFarmInventory.ps1’ will give us an object for each computer, and one of the properties for each object is the computer’s SKU (basically, model number), this will give us a quick breakdown of how many of which type we have.