Write-ProgressEx is a powershell native cmdlet that provide a simple way to show ProgressBars, PercentComplete and SecondsRemaining.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Examples v0.20 May 13, 2018
Media
Tests appveyor May 16, 2018
Write-ProgressEx v0.20 May 13, 2018
.gitignore
CHANGELOG.md v0.20 May 13, 2018
LICENSE
README.md
Write-ProgressEx.nuspec
appveyor.yml appveyor May 16, 2018

README.md

Write-ProgressEx – extended write-progress cmdlet

Build status PowerShell Gallery NuGet Write-ProgressEx icon

Write-ProgressEx extends the functionality of the standard powershell cmdlet. Write-ProgressEx is a powershell native cmdlet that provides a simple way to show ProgressBars with PercentComplete and SecondsRemaining.

The cmdlet:

  • works with pipe;
  • works with empty activity string;
  • completes all inner progresses if no parameters;
  • automatically completes with pipe;
  • automatically calculates percents, remaining seconds and elapsed time;
  • automatically displays current iteration and totals on progress bar;
  • automatically set parent id for a inner loop;
  • stores totals, current values and actual parameters into the module hashtable;
  • provides get/set cmdlets to access actual parameters;
  • uses script blocks to show messages with date, time, iterations and elapsed time on events:
    • first iteration;
    • activity changed;
    • status changed;
    • completed.
  • provides a counter functional. See Write-ProgressEx as a counter;
  • uses the caller function name or the caller script file name as the Activity;
  • accepts -ShowProgressBar Auto parameter to reduce the overhead for redrawing a screen. It recognizes None and Force values also.

Note: the cmdlet is not safe with multi-thread.

Examples

A pipe and a simple loop:

$range1 = 1..20
$range1 | Write-ProgressEx "loop 1" -Total $range1.Count -ShowMessages | ForEach-Object {
    # ....
}

$range2 = 1..15
$range2 | ForEach-Object {
    # ....
    Write-ProgressEx "loop 2" -Total $range2.Count -Increment
}

Write-ProgressEx #close all progress bars

Pipes in nested loops:

$outer = 1..20
$inner = 1..50

$outer | Write-ProgressEx "pipe nodes" -Status "outer" -Total $outer.Count -ShowMessages | ForEach-Object {
    $inner | Write-ProgressEx "pipe names" -id 1 -Status "inner" -Total $inner.Count | ForEach-Object {
        # ....
    }
}

screenshot: Write-ProgressEx

screenshot: Result messages

A long time command:

$files = Get-ChildItem $env:homepath -recurse | Write-ProgressEx -Activity $env:homepath

More samples are in the folder Examples.

Installation

Automatic install Write-ProgressEx module from the PowerShell Gallery:

Install-Module -Name Write-ProgressEx
Import-Module Write-ProgressEx

Automatic install Write-ProgressEx module from the NuGet.org:

Install-Package -Name Write-ProgressEx
Import-Module Write-ProgressEx

or manual:

  • Download and unblock the latest .zip file.
  • Extract the .zip into your $PSModulePath, e.g. ~\Documents\WindowsPowerShell\Modules.
  • Ensure the extracted folder is named Write-ProgressEx.
  • Set an execution policy to RemoteSigned or Unrestricted to execute not signed modules Set-ExecutionPolicy RemoteSigned.
  • Run Import-Module Write-ProgressEx.

Changelog

License

This project is released under the licensed under the MIT License.

mazzy@mazzy.ru