API Reference
Command
Invoke-CxHyperVVmStateChange
Invokes a native Hyper-V virtual machine state change through the Hyper-V WMI v2 provider.
Examples
Example 1: Preview a graceful shutdown request.
PS>
Invoke-CxHyperVVmStateChange -Name DC01 -Action Shutdown -Preview
Example 2: Start a selected VM and wait for the returned Hyper-V job to finish.
PS>
Invoke-CxHyperVVmStateChange -Name Lab01 -Action Start -Wait
Example 3: Start a selected VM through native Hyper-V WMI.
PS>
Invoke-CxHyperVVmStateChange -ComputerName HV01 -Name Lab01 -Action Start -Confirm
Common Parameters
This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
For more information, see about_CommonParameters.
Syntax
Invoke-CxHyperVVmStateChange [-ComputerName <string[]>] -Name <string> -Action <Start> [-JobPollIntervalMilliseconds <int>] [-JobTimeoutSeconds <int>] [-Preview] [-TimeoutSeconds <int>] [-Wait] [<CommonParameters>]#Parameters
- ComputerName string[]
- Target computer names. Use . for the local machine or provide DNS/NetBIOS names. When omitted, the local computer is targeted.
- Name string
- Virtual machine friendly name, WMI identity, or wildcard pattern resolving to one VM.
- Action HyperVVirtualMachineStateChangeAction
- Native Hyper-V state change action. Possible values: Start, Shutdown, TurnOff, Save, Pause, Resume, Reset
- Possible values:
Start,Shutdown,TurnOff,Save,Pause,Resume,Reset - JobPollIntervalMilliseconds int
- Optional delay in milliseconds between asynchronous Hyper-V job polls.
- JobTimeoutSeconds int
- Optional timeout in seconds for asynchronous Hyper-V job polling.
- Preview SwitchParameter
- Emits the non-mutating state change plan without invoking WMI.
- TimeoutSeconds int
- Optional WMI timeout in seconds used for VM discovery.
- Wait SwitchParameter
- Waits for an asynchronous Hyper-V job returned by RequestStateChange.
Outputs
ComputerX.HyperV.HyperVVirtualMachineStateChangePlan, ComputerX.HyperV.HyperVVirtualMachineStateChangeResult