Usage of inner progress bar

suggest change
1..10 | foreach-object {
        $fileName = "file_name_$_.txt"
        Write-Progress -Activity "Copying files" -Status "$($_*10) %" -Id 1 -PercentComplete ($_*10) -CurrentOperation "Copying file $fileName"
            
        1..100 | foreach-object {
            Write-Progress -Activity "Copying contents of the file $fileName" -Status "$_ %" -Id 2 -ParentId 1 -PercentComplete $_ -CurrentOperation "Copying line $_"
            
            Start-Sleep -Milliseconds 20 # stand-in for the work, for example copying a line
        }

        Start-Sleep -Milliseconds 500 # stand-in for the work, for example searching for a file

   }

Start-Sleep stands in for the work. You can run the example as it is, then replace those lines. -Id 2 -ParentId 1 draws the inner bar under the outer bar.

This is how the result looks in the PowerShell console:

This is how the result looks in the Windows PowerShell ISE:

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents