Created
February 22, 2019 15:19
-
-
Save ashdar/a9256d2ea130c48113eeb1fb913d8cea to your computer and use it in GitHub Desktop.
Revisions
-
ashdar created this gist
Feb 22, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ 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'