You are here:

WindowsManagement.com > PowerShell > PowerShell 1.0 > Write-Progress
ActiveXperts Network Monitor 2015 proactively manages network servers, devices, databases and more.

Write-Progress - PowerShell 1.0

Microsoft Windows PowerShell is a command-line shell and scripting tool based on the Microsoft .NET Framework. It is designed for system administrators, engineers and developers to control and automate the administration of Windows and applications.

More than hundred command-line tools (so called "cmdlets") can be used to perform system administration tasks and Windows Management Instrumentation (WMI). These cmdlets are easy to use, with standard naming conventions and common parameters, and standard tools for piping, sorting, filtering, and formatting data and objects.

Write-Progress


Description
Back up your Hyper-V VMs Easy & Fast. 100% built for Hyper-V. Free for 2 VMs, forever.

Usage


Options
-activity string
       A string that describes the activity about which progress is being reported.
       Will appear as the first heading above the progress bar.
        
   -status string
       A string that describes current state of the activity about which progress
       is being reported. Will appear as the second heading above the progress bar.
        
   -id int
       The activity identifier for this progress record.
        
   -percentComplete int
       The percentage of the activity that is completed.
       Use the value -1 if the percentage is unknown or not applicable.
        
   -secondsRemaining int
       The projected number of seconds remaining until the activity is completed.
       Use the value -1 if the number of seconds remaining is unknown or not applicable.
        
   -currentOperation string
       Describes the operation that is currently taking place.
        
   -parentId int
       The parent activity of the current activity. 
       Use the value -1 if the current activity has no parent activity.
        
   -completed 
       Hide the progress bar, to indicate the activity is complete.
        
   -sourceId int
       Identify the source of the record

   CommonParameters:
       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutVariable.

Example(s)
Display progress of a for loop:

PS C:\>for($i = 1; $i -lt 101; $i++ ) {for($j=0;$j -lt 10000;$j++) {} write-progress "Search in Progress" "% Complete:" -perc $i;}

Display progress while searching through the system event log messages:

PS C:\>$events = get-eventlog -logname system
PS C:\>$events | foreach-object -begin {clear-host;$i=0;$out=""} -process {if($_.message -like "*bios*") {$out=$out + $_.Message}; $i = $i+1; write-progress -activity "Searching Events" -status "Progress:" -percentcomplete ($i/$events.count*100)} -end {$out}