function foo { [cmdletbinding()] param ( [Parameter(Mandatory = $true, ValueFromPipeline=$True, ValueFromPipelineByPropertyName=$True )] [string[]] $DestinationDatabase, $TestName ) begin { $i = [int] 1 } process { foreach ($DestinationDb in $DestinationDatabase) { [pscustomobject] @{ID = $i; DestinationDatabase = $DestinationDb; TestName = $TestName} $i++ } } } $stringPiped = 'justastring-piped' $stringPassed = 'justastring-passed' $arrayPiped = @('bar-array-piped','hello-array-piped','world-array-piped') $arrayPassed = @('bar-array-passed','hello-array-passed','world-array-passed') foo -DestinationDatabase $arrayPassed -TestName 'An array of 3 objects, passed as a parameter' $arrayPiped | foo -TestName 'An array of 3 objects, piped' foo -DestinationDatabase $stringPassed -TestName 'A simple string, passed as a parameter' $stringPiped | foo -TestName 'A simple string, piped' [pscustomobject] @{ID = 99; DestinationDatabase = 'pscustomobjet-NameByPipeline'} | foo -TestName 'A complex object, piped'