Looking at Tasks under Virtual Server

Whenever Virtual Server has a task to complete (like merging a hard disk) that may take a while - it creates a task object. You have probably seen these used in some of my scripts when I want to wait for a task to complete before moving onto the next step. These task objects are really quite useful - and expose some interesting information.

The script below will retrieve all active task object from a Virtual Server instance - and then display the Task ID, description and percentage completion:

Set vs = CreateObject("VirtualServer.Application")

Set tasks = vs.Tasks
If tasks.Count = 0 Then
Wscript.Echo "There are no tasks"
Else
Wscript.Echo "Active tasks: "
For Each task in tasks
Wscript.Echo " Task: " & task.ID & " : " & task.Description & " : " & task.PercentCompleted
Next
End If

Cheers,
Ben