Re: Syntax question in context of 'ForEach'

5 views
Skip to first unread message

dave...@gmail.com

unread,
Nov 5, 2021, 12:01:00 PM11/5/21
to
On 29/10/2021 15:12, Walter H. wrote:
> Hello
>
> XXX |ForEach Write-Host $_
>
> what do I have to enter instead of XXX to get e.g.
>
> 1
> 2
> 3
> 4
> 5
>
> as output (Write-Host)?
>
> Thanks,
> Walter

Try:

1,2,3,4,5 | foreach-object -process { write-host $_ }

or perhaps

for ($x=1;$x -lt 6;$x++) { write-host $x}
Reply all
Reply to author
Forward
0 new messages