// SetPowerState sets the desired power state on a virtual machine.
SetPowerState sets the desired power state on a virtual machine.
// SetPowerState sets the desired power state on a virtual machine .
func (v *VirtualMachine) SetPowerState(state PowerState) error {
	jobPath := ole.VARIANT{}
	jobState, err := v.computerSystem.Get("RequestStateChange", uint16(state), &jobPath)
	if err != nil {
		return errors.Wrap(err, "calling RequestStateChange")
	}
	if jobState.Value().(int32) == wmi.JobStatusStarted {
		err = wmi.WaitForJob(jobPath.Value().(string))
		if err != nil {
			return errors.Wrap(err, "waiting for job")
		}
	}
	return nil
}
func ( v * VirtualMachine ) SetPowerState ( state PowerState ) error { jobPath := ole . VARIANT { } jobState , err := v . computerSystem . Get ( " " , uint16 ( state ) , & jobPath ) if err != nil { return errors . Wrap ( err , " " ) } if jobState . Value ( ) . ( int32 ) == wmi . JobStatusStarted { err = wmi . WaitForJob ( jobPath . Value ( ) . ( string ) ) if err != nil { return errors . Wrap ( err , " " ) } } return nil }
SetPowerState sets the desired power state on a virtual machine.
SetPowerState sets the desired power state on a virtual machine .