Simple but don’t understand
If I type
$tot =0
gci |%{$tot += $_.length}
It will return value
$tot = gci |%{$tot += %_.length}
It return nothing.
why ?
Simple but don’t understand
If I type
$tot =0
gci |%{$tot += $_.length}
It will return value
$tot = gci |%{$tot += %_.length}
It return nothing.
why ?
Hmmm … for me
$tot = 0
Get-ChildItem |
ForEach-Object{
$tot += $_.length
}
But what should “%_” be? What do you expect it to do? Don’t you get an error (a lot of errors?)
REgardless of the syntax , it won’t return anything. The scriptblock should spit something for the $tot variable to catch. In this case its always caught in $tot inside the foreach statement.
As @Olaf-Soyk mentioned, didn’t you get any errors with that syntax ?