TestimoX

API Reference

Class

HyperVVirtualMachineStateChangeQuery

Namespace ComputerX.HyperV
Assembly ComputerX
Modifiers static

Plans and invokes native Hyper-V virtual machine state changes through the Hyper-V WMI v2 provider.

Inheritance

  • Object
  • HyperVVirtualMachineStateChangeQuery

Methods

public static HyperVVirtualMachineStateChangeResult BuildPreviewResult(HyperVVirtualMachineStateChangePlan plan) #
Returns: HyperVVirtualMachineStateChangeResult

Converts a non-mutating plan into a result-shaped preview row.

Parameters

plan ComputerX.HyperV.HyperVVirtualMachineStateChangePlan requiredposition: 0
State change plan.

Returns

A preview result.

public static HyperVVirtualMachineJobInfo GetJob(String computerName, String jobPath, Nullable<TimeSpan> timeout = null) #
Returns: HyperVVirtualMachineJobInfo

Reads a Hyper-V job by object path.

Parameters

computerName System.String requiredposition: 0
Target computer name.
jobPath System.String requiredposition: 1
Hyper-V WMI job path.
timeout System.Nullable{System.TimeSpan} = null optionalposition: 2
Optional WMI query timeout.

Returns

Job information when the job can be found; otherwise null.

Invoke 3 overloads
public static HyperVVirtualMachineStateChangeResult Invoke(HyperVVirtualMachineStateChangePlan plan, Boolean execute, Boolean waitForJob, Nullable<TimeSpan> jobTimeout, Nullable<TimeSpan> jobPollInterval, CancellationToken cancellationToken) #
Returns: HyperVVirtualMachineStateChangeResult

Invokes a Hyper-V virtual machine state change through Msvm_ComputerSystem.RequestStateChange.

Parameters

identity System.String requiredposition: 0
Virtual machine friendly name, WMI identity, or wildcard pattern resolving to one VM.
action ComputerX.HyperV.HyperVVirtualMachineStateChangeAction requiredposition: 1
Requested state change action.
computerName System.String = null requiredposition: 2
Target computer name. Blank or . uses the local computer.
timeout System.Nullable{System.TimeSpan} = null requiredposition: 3
Optional WMI query timeout used for discovery.
execute System.Boolean = true requiredposition: 4
When false, returns the plan as a preview without invoking WMI.
cancellationToken System.Threading.CancellationToken = null requiredposition: 5
Cancellation token.

Returns

A state change request result.

public static HyperVVirtualMachineStateChangeResult Invoke(String identity, HyperVVirtualMachineStateChangeAction action, String computerName, Nullable<TimeSpan> timeout, Boolean execute, Boolean waitForJob, Nullable<TimeSpan> jobTimeout = null, Nullable<TimeSpan> jobPollInterval = null, CancellationToken cancellationToken = null) #
Returns: HyperVVirtualMachineStateChangeResult

Invokes a Hyper-V virtual machine state change and optionally waits for the returned asynchronous job.

Parameters

identity System.String requiredposition: 0
Virtual machine friendly name, WMI identity, or wildcard pattern resolving to one VM.
action ComputerX.HyperV.HyperVVirtualMachineStateChangeAction requiredposition: 1
Requested state change action.
computerName System.String requiredposition: 2
Target computer name. Blank or . uses the local computer.
timeout System.Nullable{System.TimeSpan} requiredposition: 3
Optional WMI query timeout used for discovery.
execute System.Boolean requiredposition: 4
When false, returns the plan as a preview without invoking WMI.
waitForJob System.Boolean requiredposition: 5
When true, polls the returned Hyper-V job until completion or timeout.
jobTimeout System.Nullable{System.TimeSpan} = null optionalposition: 6
Maximum time to wait for a Hyper-V job. Defaults to 120 seconds.
jobPollInterval System.Nullable{System.TimeSpan} = null optionalposition: 7
Delay between Hyper-V job polls. Defaults to one second.
cancellationToken System.Threading.CancellationToken = null optionalposition: 8
Cancellation token.

Returns

A state change request result.

Invoke(ComputerX.HyperV.HyperVVirtualMachineStateChangePlan plan, System.Boolean execute, System.Boolean waitForJob, System.Nullable{System.TimeSpan} jobTimeout, System.Nullable{System.TimeSpan} jobPollInterval, System.Threading.CancellationToken cancellationToken) #

Invokes a Hyper-V virtual machine state change from an already resolved plan.

Parameters

plan ComputerX.HyperV.HyperVVirtualMachineStateChangePlan required
Resolved state change plan.
execute System.Boolean required
When false, returns the plan as a preview without invoking WMI.
waitForJob System.Boolean required
When true, polls the returned Hyper-V job until completion or timeout.
jobTimeout System.Nullable{System.TimeSpan} required
Maximum time to wait for a Hyper-V job.
jobPollInterval System.Nullable{System.TimeSpan} required
Delay between Hyper-V job polls.
cancellationToken System.Threading.CancellationToken required
Cancellation token.

Returns

A state change request result.

InvokeAsync 2 overloads
public static Task<HyperVVirtualMachineStateChangeResult> InvokeAsync(String identity, HyperVVirtualMachineStateChangeAction action, String computerName = null, Nullable<TimeSpan> timeout = null, Boolean execute = true, CancellationToken cancellationToken = null) #
Returns: Task<HyperVVirtualMachineStateChangeResult>

Asynchronously invokes a Hyper-V virtual machine state change.

Parameters

identity System.String requiredposition: 0
Virtual machine friendly name, WMI identity, or wildcard pattern resolving to one VM.
action ComputerX.HyperV.HyperVVirtualMachineStateChangeAction requiredposition: 1
Requested state change action.
computerName System.String = null optionalposition: 2
Target computer name. Blank or . uses the local computer.
timeout System.Nullable{System.TimeSpan} = null optionalposition: 3
Optional WMI query timeout used for discovery.
execute System.Boolean = true optionalposition: 4
When false, returns the plan as a preview without invoking WMI.
cancellationToken System.Threading.CancellationToken = null optionalposition: 5
Cancellation token.

Returns

A state change request result.

public static Task<HyperVVirtualMachineStateChangeResult> InvokeAsync(String identity, HyperVVirtualMachineStateChangeAction action, String computerName, Nullable<TimeSpan> timeout, Boolean execute, Boolean waitForJob, Nullable<TimeSpan> jobTimeout = null, Nullable<TimeSpan> jobPollInterval = null, CancellationToken cancellationToken = null) #
Returns: Task<HyperVVirtualMachineStateChangeResult>

Asynchronously invokes a Hyper-V virtual machine state change and optionally waits for the returned job.

Parameters

identity System.String requiredposition: 0
Virtual machine friendly name, WMI identity, or wildcard pattern resolving to one VM.
action ComputerX.HyperV.HyperVVirtualMachineStateChangeAction requiredposition: 1
Requested state change action.
computerName System.String requiredposition: 2
Target computer name. Blank or . uses the local computer.
timeout System.Nullable{System.TimeSpan} requiredposition: 3
Optional WMI query timeout used for discovery.
execute System.Boolean requiredposition: 4
When false, returns the plan as a preview without invoking WMI.
waitForJob System.Boolean requiredposition: 5
When true, polls the returned Hyper-V job until completion or timeout.
jobTimeout System.Nullable{System.TimeSpan} = null optionalposition: 6
Maximum time to wait for a Hyper-V job. Defaults to 120 seconds.
jobPollInterval System.Nullable{System.TimeSpan} = null optionalposition: 7
Delay between Hyper-V job polls. Defaults to one second.
cancellationToken System.Threading.CancellationToken = null optionalposition: 8
Cancellation token.

Returns

A state change request result.

public static HyperVVirtualMachineStateChangePlan Plan(String identity, HyperVVirtualMachineStateChangeAction action, String computerName = null, Nullable<TimeSpan> timeout = null) #
Returns: HyperVVirtualMachineStateChangePlan

Creates a non-mutating plan for a Hyper-V virtual machine state change.

Parameters

identity System.String requiredposition: 0
Virtual machine friendly name, WMI identity, or wildcard pattern resolving to one VM.
action ComputerX.HyperV.HyperVVirtualMachineStateChangeAction requiredposition: 1
Requested state change action.
computerName System.String = null optionalposition: 2
Target computer name. Blank or . uses the local computer.
timeout System.Nullable{System.TimeSpan} = null optionalposition: 3
Optional WMI query timeout.

Returns

A state change plan.

public static HyperVVirtualMachineJobInfo WaitForJob(String computerName, String jobPath, TimeSpan timeout, TimeSpan pollInterval, CancellationToken cancellationToken = null) #
Returns: HyperVVirtualMachineJobInfo

Polls a Hyper-V job until it reaches a terminal state or the timeout expires.

Parameters

computerName System.String requiredposition: 0
Target computer name.
jobPath System.String requiredposition: 1
Hyper-V WMI job path.
timeout System.TimeSpan requiredposition: 2
Maximum time to wait.
pollInterval System.TimeSpan requiredposition: 3
Delay between polls.
cancellationToken System.Threading.CancellationToken = null optionalposition: 4
Cancellation token.

Returns

The final or most recent job information, when available.