Hi,
Can you open a bug on the documentation error at
http://connect.microsoft.com.
--
Thanks
Krishna[MSFT]
Windows PowerShell Team
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
"ktmd" <ktmd@discussions.microsoft.com> wrote in message
news:16AAFBA9-8F4C-4C57-A396-1FA9781D26FE@microsoft.com...
> All of your solutions work. The documentation is also wrong to start
> array
> count with $x=1, it should be $x=0.
>
> Thanks for your help.
>
> ktmd
>
> "Keith Hill" wrote:
>
>>
>> "ktmd" <ktmd@discussions.microsoft.com> wrote in message
>> news:896BFDC3-6188-4DC3-AFED-89EA7693E2D5@microsoft.com...
>> >I ran the following sample from Powershell Quick Reference, but I got
>> >error.
>> > Can you tell why?
>> >
>> > POSH >Get-Process |foreach {BEGIN{$x=1}
>> >>> PROCESS{$X++}
>> >>> END{"$X Processes"}}
>>
>> Begin, Process, End are parameters on the Foreach-Object cmdlet. So you
>> can
>> be explicit like so:
>>
>> Get-Process | foreach -BEGIN{$x=1} -PROCESS{$X++} -END{"$X Processes"}
>>
>> or you can rely on positional parameters:
>>
>> Get-Process | foreach {$x=1} {$X++} {"$X Processes"}
>>
>> --
>> Keith
>>
>>