This example shows two PowerShell scripts. The first one shows the possibilities for the write-progress CmdLet. The second PowerShell script is a proper example script, showing all printers. For demo purposes, some start-sleep CmdLet’s are added.

The first script has OutputSettings default 1023, all write info is shown immediately in the textbox and provided back to the result. The second example has the normal output written back to the result. But all other output is not shown.

Note that the ‘start-sleep’ is internally replaced by ‘start-wait’, which handles forms refresh better that the original ‘start-sleep’.

The example script is easy to read  for the average PowerShell user. So just take a look at the code. There is also enough information and examples on the internet for PowerScript.

'First run a a demo powershell script to show the effect of the write-progress cmdlet

'Note that the start-sleep cmdlet is internally replaced by 'start-wait'.

'This is an internal sleeper, because the original start-sleep does not allow refresh of

'the main screen


# A powerscript to show the functionality of the Write-Progress CmdLet


…. …

Write "Line 2 Test"

Write-Progress -Activity "Run Powerscript" -Status "More Info" -PercentComplete 50 ‘

    -CurrentOperation "Operation Text" -SecondsRemaining 6

start-sleep  -s 2

…. …

Write "Line 5 Test"

Write-Progress -Activity "Run Powerscript" -Status "Progress completed!" -Completed

start-sleep  -s 2



'only write commands are shown in the output, no write events


'Now a real Powerscript


# WMI query to list all properties and values of the Win32_Printer class

# This PowerShell script was generated using the WMI Code Generator, Version 1.30


param( [string]$strComputer = "." )

$colItems = get-wmiobject -class "Win32_Printer" -namespace "root\CIMV2" -computername $strComputer

$counter = 0

foreach ($objItem in $colItems) {

       write-host "Name                           :" $objItem.Name

       write-host "Default                        :" $objItem.Default

       write-host "Network                        :" $objItem.Network

       write-host "Port Name                      :" $objItem.PortName

       write-host "Driver Name                    :" $objItem.DriverName

       write-host "Server Name                    :" $objItem.ServerName

       write-host "Share Name                     :" $objItem.ShareName



       # use counter and calculation for progressbar

       $a = [int](($counter/$colItems.count)*100)

       Write-Progress -Activity "Get Printers" -Status $objItem.Name -PercentComplete $a

       start-sleep  -m 500

       $counter = $counter +1


# Just to demo, set the status to 100%

Write-Progress -Activity "Get Printers" -Status "List completed!" -PercentComplete 100

start-sleep  -m 500

# Set the status as completed

Write-Progress -Activity "Get Printers" -Status "List completed!" -Completed


'wait for a while to see that the textoutput is not updated


'Now set the result of the latest powershell script to the output

output = [#PSRESULT#]

Created with the Personal Edition of HelpNDoc: Free help authoring tool