VMware Cloud Community
Chris_Lawlor
Contributor
Contributor

PowerCli - scripted Storage vMotion

Hi

I'm looking to script some storage vmotion activity and I am new to VMware PowerCLI

I am using the script below

          Import-Csv c:\cla\clatest.csv | Foreach {Get-VM $_.Name | Move-VM -DiskStorageFormat Thin -Datastore $_.NewDatastore -RunAsync}

and I have the .csv file mentioned with the following content

NameNewDatastore
cla_vm01cla_datastore02

this VM and this datastore exist

I connect to my vCenter server and when i run the command from PowerCLI i don't get an error but nothing happens - any help would be great

these commands work perfectly so i know the PowerCLI session is logged in correctly etc

          Get-Datastore "cla_datastore01" | Get-VM | Move-VM -DiskStorageFormat Thin -Datastore "cla_datastore02" –RunAsync

          Get-Datastore "cla_datastore02" | Get-VM | Move-VM -DiskStorageFormat Thin -Datastore "cla_datastore01" –RunAsync

Thanks

Chris

0 Kudos
1 Reply
LucD
Leadership
Leadership

Since you used the RunAsync switch, the svMotion will run in the background.

The Move-VM cmdlet will come back immediately.

You can use the Get-Task cmdlet to see what the status of these background tasks is.

Or you can follow in the vSpher client or Web client.


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

0 Kudos