Pages: [1]
Print
Author Topic: sVmotion list of VM's from CSV  (Read 490 times)
esarakaitis
Administrator
Full Member
*****
Posts: 241


8223109 sack57@hotmail.com littleking57 rootinfortwayne
View Profile WWW Email
« on: March 10, 2010, 02:53:33 PM »

Code:
import-csv c:\1.csv | foreach {
   Get-VM $_.Name | move-vm -datastore (get-datastore "datastore")
}
Logged
pcli
Newbie
*
Posts: 8


View Profile
« Reply #1 on: July 08, 2010, 02:59:53 AM »

what parameters need to part of the csv file and in what order ?

also would be nice to have a script that can also read source and destination datastores

Thanks
Logged
esarakaitis
Administrator
Full Member
*****
Posts: 241


8223109 sack57@hotmail.com littleking57 rootinfortwayne
View Profile WWW Email
« Reply #2 on: July 08, 2010, 07:06:54 AM »

in the CSV you just have a list of computer names
Logged
ewannema
Administrator
Newbie
*****
Posts: 30


View Profile WWW
« Reply #3 on: July 13, 2010, 08:59:40 AM »

Re: The CSV file format.

To add a little more detail. The csv file needs to have a header row and one of the columns must be Name. There can be more columns if you are reusing a file and name can be in any column.

Here are some examples of what you should see in the file.

Name
vm001
vm002
vm003

or

User,Name,CPU,Memory,Field2
user001,vm001,1,1024,blah
user001,vm002,1,1024,blah
user001,vm003,1,1024,blah
Logged
ewannema
Administrator
Newbie
*****
Posts: 30


View Profile WWW
« Reply #4 on: July 13, 2010, 09:09:12 AM »

If you are migrating from one LUN to another you can use the examples I posted here:http://www.vmwarescripting.com/index.php?topic=1331.0.

If you are migrating specific VMs (all files) you don't need a source datastore. If you want to pick a specific destination you could modify the csv to have the following columns.

Name,DestDatastore
vm001,datastore001
vm002,datastore001
vm003,datastore003

and modify the example code to use that value:
Code:
import-csv c:\1.csv | foreach {
   Get-VM $_.Name | move-vm -datastore (get-datastore $_.DestDatastore)
}
Logged
Pages: [1]
Print
Jump to: