VMware Cloud Community
internetrush1
Contributor
Contributor
Jump to solution

powerCLI move-vm commandlet

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

0 Kudos
1 Solution

Accepted Solutions
RvdNieuwendijk
Leadership
Leadership
Jump to solution

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.

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition

View solution in original post

0 Kudos
10 Replies
RvdNieuwendijk
Leadership
Leadership
Jump to solution

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. Smiley Wink

The -Storageformat parameter should work if you move the vm to another datastore.

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
internetrush1
Contributor
Contributor
Jump to solution

So under no conditions will it move the host? 

0 Kudos
Jayden56
Enthusiast
Enthusiast
Jump to solution

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.

"You must not lose faith in humanity".
LucD
Leadership
Leadership
Jump to solution

VHD ?!?

Wrong forum ? :smileygrin:


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
RvdNieuwendijk
Leadership
Leadership
Jump to solution

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.

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
markdjones82
Expert
Expert
Jump to solution

Lol at Luc's comment

http://www.twitter.com/markdjones82 | http://nutzandbolts.wordpress.com
0 Kudos
internetrush1
Contributor
Contributor
Jump to solution

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

0 Kudos
LucD
Leadership
Leadership
Jump to solution

You could look for events with Get-VIEvent.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
internetrush1
Contributor
Contributor
Jump to solution

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

}

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

0 Kudos