Show Progress Bar

This topic contains 2 replies, has 2 voices, and was last updated by  Mikhael Kaendera 2 years, 6 months ago.

  • Author
    Posts
  • #24073

    Mikhael Kaendera
    Participant

    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

  • #24074

    Don Jones
    Keymaster

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

  • #24078

    Mikhael Kaendera
    Participant

    Thank Don. That was it.

You must be logged in to reply to this topic.