Display status information to the user for long-running tasks. Provide status updates, use the Write-Progress cmdlet shown below.

##############################################################################
##
## Invoke-LongRunningOperation
##
## From Windows PowerShell Cookbook (O'Reilly)
## by Lee Holmes (http://www.leeholmes.com/guide)
##
##############################################################################
<#

.SYNOPSIS

    Demonstrates the functionality of the Write-Progress cmdlet

#>

Set-StrictMode -Version 3

$activity = "A long running operation"

#
## Initialize the long-running operation:
$status = "Initializing"
for($counter = 0; $counter -lt 100; $counter++)
{
    $currentOperation = "Initializing item $counter"
    Write-Progress $activity $status -PercentComplete $counter -CurrentOperation $currentOperation
    Start-Sleep -m 20
}

#
## Initialize the long-running operation:
$status = "Running"
for($counter = 0; $counter -lt 100; $counter++)
{
    $currentOperation = "Running task $counter"
    Write-Progress $activity $status -PercentComplete $counter -CurrentOperation $currentOperation
    Start-Sleep -m 20
}