Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: Pipeline and non-pipelined input?

$
0
0

Correct. When input is piped in, $Computername will only contain one item at a time. If provided on the parameter, PROCESS executes once and $ComputerName contains all items.

You don’t need to determine it, though. Just build the PROCESS block to handle both.

PROCESS {
 foreach($computer in $computername) {
   # use $computer
 }
}

In the pipeline mode, the foreach is redundant but doesn’t add much extra time since it only has to loop once. Either way, $computer will only contain one name at a time, this way.


Viewing all articles
Browse latest Browse all 13067

Trending Articles