Grouping with Script Blocks

Group-Object creates groups based on object properties. For example, you could group processes by company or folder listings by extension:

Dir $env:windir | Group-Object Extension
Get-Process | Group-Object Company

If the object has no property that reflects your grouping needs, you can create one. For example, use this to split files in a folder into two groups small and large:

Dir $env:windir | Group-Object { if($_.Length -gt 100KB) { 'large' } else { 'small' }}

Posted Jun 21 2010, 08:00 AM by ps1
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.