Show Progress Bar

Welcome Forums General PowerShell Q&A Show Progress Bar

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
3 years, 8 months ago.

  • Author
    Posts
  • #24073

    Participant
    Points: 0
    Rank: Member

    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

    Keymaster
    Points: 1,704
    Helping HandTeam Member
    Rank: Community Hero

    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

    Participant
    Points: 0
    Rank: Member

    Thank Don. That was it.

The topic ‘Show Progress Bar’ is closed to new replies.