Hello everyone,
I have created a VM the following way:
Hi Yaniv,
according to the SDK the PowerOnVM method requires one parameter. You can specify the ManagedObjectReference of a host. Or you can specify $null. In that case the VM is started on the currently associated host.
$nVM.PoweronVM($null)
But why don't you use the Start-VM cmdlet to start the VM?
$newVM | Start-VM
If you use the PowerShell Get-Member cmdlet you can see which methods and properties an object has. E.g.:
$nVM | Get-Member
Regards, Robert
Message was edited by: RvdNieuwendijk Modified the part about the required parameter.
Hi Yaniv,
according to the SDK the PowerOnVM method requires one parameter. You can specify the ManagedObjectReference of a host. Or you can specify $null. In that case the VM is started on the currently associated host.
$nVM.PoweronVM($null)
But why don't you use the Start-VM cmdlet to start the VM?
$newVM | Start-VM
If you use the PowerShell Get-Member cmdlet you can see which methods and properties an object has. E.g.:
$nVM | Get-Member
Regards, Robert
Message was edited by: RvdNieuwendijk Modified the part about the required parameter.
Thank you. The '$nVM.PowerOnVM_Task($null)' worked.
BTW, what is the difference between the two?
Thanks
Most of the API methods that are made available through PowerCLI come in 2 flavours, the ones ending in _task and the ones that don't.
The ones ending in _task will return immediatly to your script and place a Task object in the pipeline.
The method will execute in the background (asynchronous).
The methods without _task will wait till the actual task is finished.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks, I got this one...
I meant, what is the difference between $nVM.PowerOnVM() and '$nVM | Start-VM'
Thanks
Start-VM is a PowerCLI cmdlet, and PowerOnVm_Task is a vSphere API method.
You can't use the same object to call these.
The PowerCLI cmdlet works like this
$newVM = New-VM ....
Start-VM -VM $newVM
and the method like this
$nVM = Get-View $newVM
$nVM.PowerOnVm_Task($null)
or like this
$newVM.ExtensionData.PowerOnVm_Task($null)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference