ETidalgo
8/19/2018 - 10:20 PM

Demonstrate begin, process, end blocks in pipeline


function Demonstrate-Pipeline
{
    [OutputType([Nullable])]
    param([parameter(mandatory, valueFromPipeline, valueFromPipelineByPropertyName)][string]$ReportName)

    begin {
        write-host "Beginning"
    }

    process {
        write-host "Processing $ReportName"
    }

    end {
        write-host "Finishing"
    }
}

'Lodestar Accruals Report Summary', 'Lodestar Accruals Report Details', 'Lodestar Shipping Margin Summary', 'Foodstuffs Accruals Details' | % { Demonstrate-Pipeline $_ }
'Lodestar Accruals Report Summary', 'Lodestar Accruals Report Details', 'Lodestar Shipping Margin Summary', 'Foodstuffs Accruals Details' | Demonstrate-Pipeline