Invoke-XenTask

Last published : Nov 12, 2026
Invokes an operation on a Task object.

Syntax

Invoke-XenTask [-Task] <Task> -XenAction {Cancel} [-PassThru] [-BestEffort]
    [-SessionOpaqueRef <string>] [-WhatIf] [-Confirm] [-Async] [<CommonParameters>]
Invoke-XenTask [-Ref] <XenRef[Task]> -XenAction {Cancel} [-PassThru] [-BestEffort]
    [-SessionOpaqueRef <string>] [-WhatIf] [-Confirm] [-Async] [<CommonParameters>]
Invoke-XenTask [-Uuid] <guid> -XenAction {Cancel} [-PassThru] [-BestEffort]
    [-SessionOpaqueRef <string>] [-WhatIf] [-Confirm] [-Async] [<CommonParameters>]
Invoke-XenTask [-Name] <string> -XenAction {Cancel} [-PassThru] [-BestEffort]
    [-SessionOpaqueRef <string>] [-WhatIf] [-Confirm] [-Async] [<CommonParameters>]

Description

Invokes an operation on a Task object. Use the -XenAction parameter to select which operation to perform.
Cancel: Request that a task be cancelled. Note that a task may fail to be cancelled and may complete or fail normally and note that, even when a task does cancel, it might take an arbitrary amount of time.

Parameters

-Async

If set, the operation runs asynchronously and returns a Task object that can be used to track its progress.
Attribute Value
Type SwitchParameter
Required False
Position Named
Accepts pipeline input False

-BestEffort

If set, the cmdlet continues processing further objects instead of throwing a terminating error when an operation fails for one object.
Attribute Value
Type SwitchParameter
Required False
Position Named
Accepts pipeline input False

-Confirm

Prompts for confirmation before running the cmdlet.
Attribute Value
Type SwitchParameter
Required False
Position Named
Accepts pipeline input False
Aliases cf

-Name

The name of the Task to operate on.
Attribute Value
Type string
Required True
Position 0
Accepts pipeline input True (ByPropertyName)
Aliases name_label

-PassThru

If set, the cmdlet returns the affected object. By default the cmdlet does not generate any output.
Attribute Value
Type SwitchParameter
Required False
Position Named
Accepts pipeline input False

-Ref

The Task object to operate on, specified by its opaque reference.
Attribute Value
Type XenRef[Task]
Required True
Position 0
Accepts pipeline input True (ByPropertyName)
Aliases opaque_ref

-SessionOpaqueRef

The session object on which to run the cmdlet. This overrides the default session and lets you target a specific open XenServer connection.
Attribute Value
Type string
Required False
Position Named
Accepts pipeline input False

-Task

The Task object to operate on.
Attribute Value
Type Task
Required True
Position 0
Accepts pipeline input True (ByValue)

-Uuid

The UUID of the Task to operate on.
Attribute Value
Type guid
Required True
Position 0
Accepts pipeline input True (ByPropertyName)

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.
Attribute Value
Type SwitchParameter
Required False
Position Named
Accepts pipeline input False
Aliases wi

-XenAction

Selects which action to use.
Attribute Value
Type XenTaskAction
Required True
Position Named
Accepts pipeline input False
Accepted values Cancel

Inputs

  • Task
  • XenRef[Task]
  • guid
  • string

Outputs

  • System.Object

Examples

Example 1: Run the Cancel operation

PS> Get-XenTask -Name "Demo Task" | Invoke-XenTask -XenAction Cancel
Invokes the Cancel operation on a Task.

Example 2: Run the Cancel operation by name

PS> Invoke-XenTask -XenAction Cancel -Name "Demo Task"
Invokes the Cancel operation on a Task. -Name matches on name\_label, which is not unique, so every match is operated on.

Example 3: Run Cancel asynchronously

PS> Invoke-XenTask -Name "Demo Task" -XenAction Cancel -Async -PassThru | Wait-XenTask -ShowProgress
Runs the same operation asynchronously and follows the task it returns.
  • Class: Task
  • Using the XenServer PowerShell module