API Reference
HyperVVirtualMachineStateChangeQuery
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) #HyperVVirtualMachineStateChangeResultConverts a non-mutating plan into a result-shaped preview row.
Parameters
- plan ComputerX.HyperV.HyperVVirtualMachineStateChangePlan
- State change plan.
Returns
A preview result.
public static HyperVVirtualMachineJobInfo GetJob(String computerName, String jobPath, Nullable<TimeSpan> timeout = null) #HyperVVirtualMachineJobInfoReads a Hyper-V job by object path.
Parameters
- computerName System.String
- Target computer name.
- jobPath System.String
- Hyper-V WMI job path.
- timeout System.Nullable{System.TimeSpan} = null
- Optional WMI query timeout.
Returns
Job information when the job can be found; otherwise null.
public static HyperVVirtualMachineStateChangeResult Invoke(HyperVVirtualMachineStateChangePlan plan, Boolean execute, Boolean waitForJob, Nullable<TimeSpan> jobTimeout, Nullable<TimeSpan> jobPollInterval, CancellationToken cancellationToken) #HyperVVirtualMachineStateChangeResultInvokes a Hyper-V virtual machine state change through Msvm_ComputerSystem.RequestStateChange.
Parameters
- identity System.String
- Virtual machine friendly name, WMI identity, or wildcard pattern resolving to one VM.
- action ComputerX.HyperV.HyperVVirtualMachineStateChangeAction
- Requested state change action.
- computerName System.String = null
- Target computer name. Blank or . uses the local computer.
- timeout System.Nullable{System.TimeSpan} = null
- Optional WMI query timeout used for discovery.
- execute System.Boolean = true
- When false, returns the plan as a preview without invoking WMI.
- cancellationToken System.Threading.CancellationToken = null
- 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) #HyperVVirtualMachineStateChangeResultInvokes a Hyper-V virtual machine state change and optionally waits for the returned asynchronous job.
Parameters
- identity System.String
- Virtual machine friendly name, WMI identity, or wildcard pattern resolving to one VM.
- action ComputerX.HyperV.HyperVVirtualMachineStateChangeAction
- Requested state change action.
- computerName System.String
- Target computer name. Blank or . uses the local computer.
- timeout System.Nullable{System.TimeSpan}
- Optional WMI query timeout used for discovery.
- execute System.Boolean
- When false, returns the plan as a preview without invoking WMI.
- waitForJob System.Boolean
- When true, polls the returned Hyper-V job until completion or timeout.
- jobTimeout System.Nullable{System.TimeSpan} = null
- Maximum time to wait for a Hyper-V job. Defaults to 120 seconds.
- jobPollInterval System.Nullable{System.TimeSpan} = null
- Delay between Hyper-V job polls. Defaults to one second.
- cancellationToken System.Threading.CancellationToken = null
- 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
- Resolved state change plan.
- execute System.Boolean
- When false, returns the plan as a preview without invoking WMI.
- waitForJob System.Boolean
- When true, polls the returned Hyper-V job until completion or timeout.
- jobTimeout System.Nullable{System.TimeSpan}
- Maximum time to wait for a Hyper-V job.
- jobPollInterval System.Nullable{System.TimeSpan}
- Delay between Hyper-V job polls.
- cancellationToken System.Threading.CancellationToken
- Cancellation token.
Returns
A state change request result.
public static Task<HyperVVirtualMachineStateChangeResult> InvokeAsync(String identity, HyperVVirtualMachineStateChangeAction action, String computerName = null, Nullable<TimeSpan> timeout = null, Boolean execute = true, CancellationToken cancellationToken = null) #Task<HyperVVirtualMachineStateChangeResult>Asynchronously invokes a Hyper-V virtual machine state change.
Parameters
- identity System.String
- Virtual machine friendly name, WMI identity, or wildcard pattern resolving to one VM.
- action ComputerX.HyperV.HyperVVirtualMachineStateChangeAction
- Requested state change action.
- computerName System.String = null
- Target computer name. Blank or . uses the local computer.
- timeout System.Nullable{System.TimeSpan} = null
- Optional WMI query timeout used for discovery.
- execute System.Boolean = true
- When false, returns the plan as a preview without invoking WMI.
- cancellationToken System.Threading.CancellationToken = null
- 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) #Task<HyperVVirtualMachineStateChangeResult>Asynchronously invokes a Hyper-V virtual machine state change and optionally waits for the returned job.
Parameters
- identity System.String
- Virtual machine friendly name, WMI identity, or wildcard pattern resolving to one VM.
- action ComputerX.HyperV.HyperVVirtualMachineStateChangeAction
- Requested state change action.
- computerName System.String
- Target computer name. Blank or . uses the local computer.
- timeout System.Nullable{System.TimeSpan}
- Optional WMI query timeout used for discovery.
- execute System.Boolean
- When false, returns the plan as a preview without invoking WMI.
- waitForJob System.Boolean
- When true, polls the returned Hyper-V job until completion or timeout.
- jobTimeout System.Nullable{System.TimeSpan} = null
- Maximum time to wait for a Hyper-V job. Defaults to 120 seconds.
- jobPollInterval System.Nullable{System.TimeSpan} = null
- Delay between Hyper-V job polls. Defaults to one second.
- cancellationToken System.Threading.CancellationToken = null
- Cancellation token.
Returns
A state change request result.
public static HyperVVirtualMachineStateChangePlan Plan(String identity, HyperVVirtualMachineStateChangeAction action, String computerName = null, Nullable<TimeSpan> timeout = null) #HyperVVirtualMachineStateChangePlanCreates a non-mutating plan for a Hyper-V virtual machine state change.
Parameters
- identity System.String
- Virtual machine friendly name, WMI identity, or wildcard pattern resolving to one VM.
- action ComputerX.HyperV.HyperVVirtualMachineStateChangeAction
- Requested state change action.
- computerName System.String = null
- Target computer name. Blank or . uses the local computer.
- timeout System.Nullable{System.TimeSpan} = null
- Optional WMI query timeout.
Returns
A state change plan.
public static HyperVVirtualMachineJobInfo WaitForJob(String computerName, String jobPath, TimeSpan timeout, TimeSpan pollInterval, CancellationToken cancellationToken = null) #HyperVVirtualMachineJobInfoPolls a Hyper-V job until it reaches a terminal state or the timeout expires.
Parameters
- computerName System.String
- Target computer name.
- jobPath System.String
- Hyper-V WMI job path.
- timeout System.TimeSpan
- Maximum time to wait.
- pollInterval System.TimeSpan
- Delay between polls.
- cancellationToken System.Threading.CancellationToken = null
- Cancellation token.
Returns
The final or most recent job information, when available.
Inherited Methods
public override Boolean Equals(Object obj) #BooleanParameters
- obj Object