PoshCode Archive  Artifact [5c0334f5b4]

Artifact 5c0334f5b4e3a387d2b543cca8d8fcbf6fac69a34341bacb774350151fd9ff13:

  • File Add-Counter.ps1 — part of check-in [84cbfb14a3] at 2018-06-10 13:48:46 on branch trunk — Function Add-Counter (adds Count NoteProperty to pipeline input to keep a running row count for display); sample usage: (user: BillBarry size: 785)

# encoding: ascii
# api: powershell
# title: Add-Counter
# description: Function Add-Counter (adds Count NoteProperty to pipeline input to keep a running row count for display); sample usage:
# version: 0.1
# type: function
# author: BillBarry
# license: CC0
# function: Add-Counter
# x-poshcode-id: 5016
# x-archived: 2014-03-30T06:46:50
# x-published: 2014-03-24T20:00:00
#
# Get-Service | Add-Counter | FT Count,Name,Status -AutoSize
#
Function Add-Counter {
    [CmdletBinding()]
    Param(
        [parameter(Mandatory=$true, ValueFromPipeline=$true)] $input,
        [string] $Name='Count'
    )
    BEGIN { $i = 0;}
    PROCESS {
        $i++;
        return Add-Member -InputObject $_ -MemberType NoteProperty -Name $Name -Value $i -PassThru
    }
}