Begin

The begin block runs before pipeline-processing starts. A pipeline that contains several commands will run each of the begin blocks for each command in turn first.

The following example shows a short function with a begin block:

function Show-Pipeline {
begin {
Write-Host 'Pipeline start'
}
}

The content of the begin block runs before the pipeline starts, before any pipeline input is accepted.

If a parameter accepts pipeline input, that input is not available to the begin block.

Begin can be used to create things that are reused by the process block, in essence setting up the initial conditions for a loop.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.140.111