Wait-AlTask

SYNOPSIS

Waits for App Layering task(s) (like an IPS export or prepare job) to complete.

SYNTAX

Wait-AlTask [-InputObject <PSObject>] [[-WorkTicketId] <Int64>] [-PollInterval <Int32>]
 [-AdditionalStates <String[]>] [-ConnectionId <Guid>] [<CommonParameters>]
<!--NeedCopy-->

DESCRIPTION

The Wait-AlTask cmdlet monitors the status of an App Layering task, identified by its WorkTicketId (alias TaskId), and pauses execution until the task reaches a terminal state (e.g., Completed, Failed, Canceled).

This cmdlet is designed to work with long-running asynchronous operations initiated by other cmdlets, such as Start-AlIpsExport or Start-AlIpsPrepare. It periodically polls the App Layering appliance (using the specified or default -PollInterval) to check the task’s progress.

You can identify the task(s) to wait for in several ways:

Using the pipeline (-InputObject parameter):

  • Pipe the output object(s) directly from the relevant ‘Start-Al*’ command (e.g., $task | Wait-AlTask).
  • Pipe one or more Task IDs directly (e.g., 123, 456 | Wait-AlTask).
  • Pipe a custom object or hashtable containing a ‘TaskId’ property (TaskId value can be a single ID or an array of IDs).

Provide the identifier explicitly using the -WorkTicketId (or -TaskId) parameter.

Once the task finishes, this cmdlet outputs an object containing the final status and results of the operation.

EXAMPLES

Example 1

PS C:\> Wait-AlTask -WorkTicketId 1234
<!--NeedCopy-->

This command waits for the App Layering task with ID 1234 to complete.

Example 2

PS C:\> 1114, 629 | Wait-AlTask
PS C:\> @(1114, 629) | Wait-AlTask
<!--NeedCopy-->

Both of these commands wait for the App Layering tasks to complete, with IDs 1114 and 629, by piping the IDs directly to the cmdlet.

Example 3

PS C:\> $exportTask = Start-AlIpsExport -ConnectorConfigId "063A0697-ACDF-43BB-969B-AA69F1419757" -SourceDisk "[DatastoreName] VMFolder/disk.vmdk" -OutputDiskName "MyExportedDisk"
PS C:\> $exportTask | Wait-AlTask
<!--NeedCopy-->

This example first starts an export task and stores the resulting task object in the $exportTask variable. The second command then pipes this task object to Wait-AlTask to wait for the task to complete.

Example 4

PS C:\> @{"TaskId" = @(1114, 629)} | Wait-AlTask
<!--NeedCopy-->

This command waits for the completion of tasks 1114 and 629 by piping a hashtable containing a TaskId key whose value is an array of the task IDs.

Example 5

PS C:\> New-Object PSObject -Property @{TaskId = @(1114, "629")} | Wait-AlTask
<!--NeedCopy-->

Similar to the previous example, this command waits for the completion of tasks 1114 and 629 by piping a custom PSObject that has a TaskId property containing an array of the IDs.

Example 6

PS C:\> Wait-AlTask -WorkTicketId 1234 -AdditionalStates ActionRequired, Stalled
<!--NeedCopy-->

This example demonstrates how to wait for the task with ID 1234 to reach a specific set of states. In addition to the default terminal states (like Complete, Failed, or Canceled), this command also waits for ActionRequired or Stalled. This allows for more flexible task monitoring beyond simple completion.

PARAMETERS

-AdditionalStates

Specifies one or more additional states to wait for, aside from the default terminal states (e.g., Complete, Failed). This is useful for stopping the wait on conditions that are not final, such as ActionRequired or Stalled. The command will conclude its wait when the task enters any specified additional state or any terminal state.

Type: String[]
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
<!--NeedCopy-->

-ConnectionId

Specifies the connection to the App Layering Appliance to use for this operation.

This is the GUID returned by Connect-AlAppliance.

If omitted, the command uses the current connection automatically if it’s the only one active. When multiple sessions are active, the GUID of the most recently used connection is used.

Type: Guid
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
<!--NeedCopy-->

-InputObject

Accepts input via the pipeline to specify the task(s) to wait for. This parameter offers flexibility in how tasks are provided. It can process:

  • Task objects output by ‘Start-Al*’ cmdlets (automatically extracts the TaskId).
  • Single Task IDs (System.Int64).
  • Arrays of Task IDs (System.Int64[]).
  • Hashtables or PSCustomObjects containing a ‘TaskId’ key/property (value can be a single Int64 ID or an array of Int64 IDs).

Refer to the examples section for detailed usage patterns. Cannot be used with -WorkTicketId

Type: PSObject
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
<!--NeedCopy-->

-PollInterval

Specifies the interval, in seconds, between status check requests sent to the App Layering appliance for the specified task. The value must be an integer between 5 and 300 (inclusive). Shorter intervals provide more responsive updates but increases load on the appliance. Longer intervals reduce load but take longer to detect completion. The default interval is 10 seconds.

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
<!--NeedCopy-->

-WorkTicketId

Specifies the unique identifier (WorkTicketId or TaskId) of the App Layering background task to wait for. This identifier is typically obtained from the output object of a command that initiated an asynchronous operation (e.g., Start-AlIpsExport, Start-AlIpsPrepare). This parameter accepts pipeline input by property name (WorkTicketId or TaskId) directly from such objects, making it easy to chain commands like: Start-AlIpsPrepare ... | Wait-AlTask

This parameter is mandatory if not providing input via the pipeline.

Type: Int64
Parameter Sets: (All)
Aliases: TaskId

Required: False
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
<!--NeedCopy-->

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

System.Int64

OUTPUTS

[WorkTicketResult[]] (Array)

Returns the status and details of the monitored tasks once they reach a terminal state or a state specified by -AdditionalStates. Each result includes current state, error messages if applicable, and any output generated by the task.

  • Id [Int64]
  • TitleResourceId [String]
  • ResourceArgs [List<String>]
  • State [WorkItemState] Possible values:
    • NotStarted (0)
    • Pending (1)
    • Running (2)
    • Complete (3)
    • Stalled (4)
    • Canceling (5)
    • Canceled (6)
    • Failed (7)
    • ActionRequired (8)
    • DoneWithErrors (9)
  • Status [String]
  • Description [String]
  • UserName [String]
  • DateCreated [Nullable<DateTime>]
  • DateLastModified [Nullable<DateTime>]
  • Hidden [Boolean]
  • MustCancelAll [Boolean]
  • WorkItems [WorkItemResult[]]
    • Id [Int64]
    • WorkTicketId [Int64]
    • ItemId [Int64]
    • CancelRequested [Boolean]
    • IsCancelable [Boolean]
    • ItemType [EntityType] Possible values:
      • Unknown (0)
      • Folder (1)
      • Group (2)
      • ActiveDirectoryEntity (3)
      • User (4)
      • DirectoryJunction (5)
      • ManagementAppliance (6)
      • CacheAppliance (7)
      • Layer (8)
      • LayerRevision (9)
      • OsLayer (10)
      • OsLayerRevision (11)
      • AppLayer (12)
      • AppLayerRevision (13)
      • MaintenanceSchedule (14)
      • Desktop (15)
      • UserDesktop (16)
      • InstallMachine (17)
      • Broker (18)
      • Collection (19)
      • UserDesktopCollection (20)
      • SessionHostCollection (21)
      • SessionHost (22)
      • ManagedMachine (23)
      • Image (24)
      • PlatformLayer (25)
      • PlatformLayerRevision (26)
      • Recipe (27)
      • Appliance (28)
      • PlatformType (29)
      • HypervisorPlatformType (30)
      • ProvisioningPlatformType (31)
      • BrokerPlatformType (32)
      • ZombieLayerRevision (33)
      • RemoteFileShare (34)
      • RemoteFileShareTable (35)
      • ImportExportFileShare (36)
      • UserRole (37)
      • UserRight (38)
      • FileShare (39)
      • WorkItem (40)
      • ConnectorCachedLayer (41)
      • LayerRepository (42)
      • ConnectorCachedCeBootImage (43)
      • ConnectorCachedDisk (44)
      • Configuration (45)
      • IpsTaskContext (46)
    • ItemName [String]
    • State [WorkItemState] Possible values:
      • NotStarted (0)
      • Pending (1)
      • Running (2)
      • Complete (3)
      • Stalled (4)
      • Canceling (5)
      • Canceled (6)
      • Failed (7)
      • ActionRequired (8)
      • DoneWithErrors (9)
    • TimeoutInSec [Int64]
    • DateCreated [Nullable<DateTime>]
    • DateLastModified [Nullable<DateTime>]
    • DateWillTimeout [Nullable<DateTime>]
    • Status [String]
    • StatusResourceId [String]
    • ResourceArgs [List<Object>]

NOTES

Wait-AlTask