Measure-Group.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
function Measure-Group { [CmdletBinding()] param( [Parameter(Mandatory,ValueFromPipeline)] [ValidateNotNullOrEmpty()] [Microsoft.PowerShell.Commands.GroupInfo[]] $InputObject , [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [string] $Property ) Process { $InputObject | ForEach-Object { $Measurement = Measure-Object -Data $_.Group -Property $Property Add-Member -InputObject $Measurement -MemberType NoteProperty -Name Name -Value $_.Name -PassThru } } } New-Alias -Name mg -Value Measure-Group -Force |