Curious as to whether or not i can move just the Datastore the vm is stored on and only the datastore the vm is stored on with the following:
Move-VM -VM $VMobj -Datastore $destDatastore -DiskStorageFormat 'Thick'
1 Anyone shine some light on this? The documentation does give an example with the -destination parameter but no documentation on how to tell it to explicitely move one aspect of the VM or if the commandlet works that way.
2 Also, the THICK parameter doesnt seem to work at all as i have moved the VMs to and from datastores and they are still Thin.
Thanks!
EDIT: Thick parameter wasnt working because the NFS i was attempting to transfer in was not in the same vcenter.
question 1 still applies
EDIT2: For clarity
The Move-VM cmdlet will only move a virtual machine to another host if you use the -Destination parameter and specify a host where the virtual machine should move to. Your command will not move the vm to another host.
Remember that the Move-VM cmdlet moves vm's, not datastores or hosts.
That command will work fine. But I would say that it moves a virtual machine to another datastore instead of that it moves the datastore.
The -Storageformat parameter should work if you move the vm to another datastore.
So under no conditions will it move the host?
Hi
Welcome to the communities.
Host will not move as command given to move only data store .
you can keep vhd any datstore & link with host.
The Move-VM cmdlet will only move a virtual machine to another host if you use the -Destination parameter and specify a host where the virtual machine should move to. Your command will not move the vm to another host.
Remember that the Move-VM cmdlet moves vm's, not datastores or hosts.
Lol at Luc's comment
Now that this code works, im looking to log any errors that might result in the overallocation of resources; the following does not work:
try{
move-vm -VM $Vm -destination $dest
}catch{
write-log "Some log here $_ "
}
Any ideas how i can catch WHICH vm's do not end up moving or finishing their move?
Thanks
You could look for events with Get-VIEvent.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The get-VIevent method seems a bit contrived to simply receive an exception from powershell itself.
First, lets see if this works... Will update if / when i run this script again.
Trap
[Exception] {#logs all errors and limits output on screen
write-log "$("$UseInfo`t$_. - Line:(" + $($_.InvocationInfo.ScriptLineNUmber)+":"+$($_.InvocationInfo.OffsetInLine)+ ") " + $($_.InvocationInfo.Line))"
continue
}
I see, if you want to catch PowerShell execeptions then Get-VIEvent is indeed not the way to go.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference