PowerShell Using the progress bar Usage of inner progress bar


Example

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 # sleep simulates working code, replace this line with your executive code (i.e. file copying)
        }

        Start-Sleep -Milliseconds 500 # sleep simulates working code, replace this line with your executive code (i.e. file search)

   }

Please note that for brevity this example does not contain any executive code (simulated with Start-Sleep). However it is possible to run it directly as is and than modify and play with it.

This is how result looks in PS console: Powershell console inner progress bar

This is how result looks in PS ISE: Powershell ISE inner progress bar