hi,
I have the following simple script, this is not running in a function, its running direct in the script
[CmdletBinding()]
Param(
[Parameter(ValueFromPipeline=$True)]
[String[]]$Computers
)
Begin {
Write-host "Starting Point" -ForegroundColor Yellow
}
Process {
Write-Host $Computers.GetType() -ForegroundColor Red
Write-Host $Computers
}
End {
Write-host "Remove Variable" -ForegroundColor Yellow
}
But I don't understand the behavior of the output if the script executed like the following
**.\TestPipline.ps1 -Computers "1","2"**
The output is Starting Point
System.String[]
1 2
Remove Variable
If the script executed like the following "1","2" |.\TestPipline.ps1
The result is displayed correctly, which is like this
Starting Point
System.String[]
1
System.String[]
2
Remove Variable
Notice that in the first execution, the 1 and 2 are passed as a single line(object), but on the second execution, the 1 first passed and processed and then 2.
what I am missing here, how to make 1 and 2 always passed and processed separately