Author Posts

April 8, 2015 at 6:49 am

I am trying to get my script to show a progress bar ising the writre -progress cmdlet. I am getting the missing statement body for loop.

$fso = Get-ChildItem -Recurse -path "\\vfs04\Users$\kaendm\Desktop\Test\*.txt)
0ni"

for($i = 1; $i -lt 101; $i++ )

get-content $fso | select-string 'Host'| export-csv -path c:\powershell\PrinterNames.csv

{write-progress -activity Updating -status 'Progress->' -percentcomplete $i -currentOperation OuterLoop; `
for($j = 1; $j -lt 101; $j++ )
{write-progress -id 1 -activity Updating -status 'Progress' -percentcomplete $j -currentOperation InnerLoop} }

Updating
Progress ->
[ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo]
OutsideLoop
Updating
Progress
[oooooooooooooooooo ]
InnerLoop

April 8, 2015 at 6:56 am

Your first For construct is not followed by a { script body }. Instead, it is followed by Get-Content. That's the complaint from PowerShell.

April 8, 2015 at 8:12 am

Thank Don. That was it.