# encoding: ascii
# api: powershell
# title: Invoke-LongRunningOperat
# description: From Windows PowerShell Cookbook (O’Reilly) by Lee Holmes
# version: 0.1
# type: function
# author: Lee Holmes
# license: CC0
# x-poshcode-id: 2182
# x-archived: 2016-03-19T02:52:53
# x-published: 2011-09-09T21:41:00
#
#
##############################################################################
##
## 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 Latest
$activity = "A long running operation"
$status = "Initializing"
## Initialize the long-running operation
for($counter = 0; $counter -lt 100; $counter++)
{
$currentOperation = "Initializing item $counter"
Write-Progress $activity $status -PercentComplete $counter `
-CurrentOperation $currentOperation
Start-Sleep -m 20
}
$status = "Running"
## Initialize the long-running operation
for($counter = 0; $counter -lt 100; $counter++)
{
$currentOperation = "Running task $counter"
Write-Progress $activity $status -PercentComplete $counter `
-CurrentOperation $currentOperation
Start-Sleep -m 20
}