param($property=$null)
begin { $script:hash = @{} } process { if(($script:property) -and ( $_.$script:property )) { $obj = ($_ | select-object $script:property).$script:property } else { $obj = $_ $script:property = "Name" } if( $script:hash.$obj -eq $null ) { $script:hash.$obj = @(1, $_); } else { $script:hash.$obj[0]++ } } end { foreach($key in $script:hash.keys | sort) { $result = new-object System.Management.Automation.PsObject add-member -input $Result -type Note* -Name Input -value $script:hash.$Key[1] add-member -input $Result -type Note* -Name $script:property -value $Key add-member -input $Result -type Note* -Name Count -value $script:hash.$Key[0] write-output $result } }