Problem
You want to display status information to the user for longrunning tasks.
Solution
To provide status updates, use the WriteProgress cmdlet as shown in Example 125.
Example 125. Using the WriteProgress cmdlet to display status updates
$activity = "A longrunning operation"
$status = "Initializing" ## Initialize the longrunning operation for($counter = 0; $counter lt 100; $counter++) {
$currentOperation = "Initializing item $counter" WriteProgress $activity $status PercentComplete $counter ` CurrentOperation $currentOperation StartSleep m 20 }
$status = "Running" ## Initialize the longrunning operation for($counter = 0; $counter lt 100; $counter++) {
$currentOperation = "Running task $counter" WriteProgress $activity $status PercentComplete $counter ` CurrentOperation $currentOperation StartSleep m 20 }