begin (and end) blocks dont 'set' variable from pipeline?

This surprised me. When a variable is set via pipeline, the begin block doesn’t ‘see’ it? If I set the variable via a parameter argument, the begin block sees it. I was looking for a way to determine if the variable was set, but not sure how i can do that if I allow pipeline input.

scripts:\
PS > . .\functest-pipeline.ps1

scripts:\
PS > test-pipeline -list "asdf" -ver
VERBOSE: [begin]: start
asdf
VERBOSE: asdf
VERBOSE: [process]: start
asdf
VERBOSE: [process]: asdf
VERBOSE: process block foreach item:
VERBOSE: end block

scripts:\
PS > "asdf" | test-pipeline -ver
VERBOSE: [begin]: start

VERBOSE:
VERBOSE: no list
VERBOSE: [process]: start
asdf
VERBOSE: [process]: asdf
VERBOSE: process block foreach item:
VERBOSE: end block

scripts:\
function test-pipeline {
  [CmdletBinding()]
  param (
    [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, Position = 0)]
    #[ValidateNotNullOrEmpty()]
    [alias("name")]
    [string[]]
    $list  )
  
  begin {
    write-verbose "[begin]: begin"
    "$list"
    write-verbose "$list"
    if (!($list)) {
      write-verbose "no list"
    }
  }
  
  process {
    write-verbose "[process]: begin"
    "$list"
    write-verbose "[process]: $list"
    foreach ($item in $list) {
      write-verbose "process block foreach item: $vm"
    }
  }
  
  end {
    write-verbose "end block"
    $results
  }
}

I would share below link rather than explaining the same here.

https://www.petri.com/anatomy-powershell-advanced-function

From further research, including the link above, it seems that the pipeline variable is not available in either the begin or process blocks.

Additionally, you can use

$PSCmdlet.MyInvocation.ExpectingInput

to determine if there is input coming from the pipeline.

Updated test script:

function test-pipeline {
  [CmdletBinding()]
  param (
    [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName, Position = 0)]
    #[ValidateNotNullOrEmpty()]
    [alias("name")]
    [string[]]
    $list  )
  
  begin {
    write-verbose "[begin]: begin"
    "$list"
    write-verbose "$list"
    if (!($list)) {
      write-verbose "no list"
    }

    $pipeline = $PSCmdlet.MyInvocation.ExpectingInput

    if (!($pipeline) -and (!($list))) {
      write-verbose "No pipeline, no param arg."
    }
  } #end begin
    
    #write-verbose 
  
  
  process {
    write-verbose "[process]: begin"
    "$list"
    write-verbose "[process]: $list"
    foreach ($item in $list) {
      write-verbose "process block foreach item: $vm"
    }
  }
  
  end {
    write-verbose "end block"
    $results
  }
}

#https://communary.net/2015/01/12/quick-tip-determine-if-input-comes-from-the-pipeline-or-not/