VMware Cloud Community
Tigerstolly
Enthusiast
Enthusiast
Jump to solution

Simple question - starting VM's from a list in a CSV

Hi,

As part of a larger script i want to start some VM's from a list in a CSV, using this bit of script

$vmcsv = import-csv "c:\vi\vm_dr_startup.csv"

foreach ($vm in $vmcsv)

{

get-vm $vm | start-vm

write-host "It lives !!!!"

}

It doesn't quite work, i get the error " VM with name '@{vm=DR_VM1}' not found, using the specified filter(s)."

So i'm obviously doing something wrong but can't figure out what. Any help would be appreciated !

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
yboychev
Hot Shot
Hot Shot
Jump to solution

Hi,

You are not using correctly the data from the csv file. Whne you import a csv file the result is an array of PSCustomObject objects. So in order to make your script work you should modify it like this ...

foreach ($obj in $vmcsv) {

get-Vm $obj.vm | Start-Vm

}

\Yavor

PS I guess DR_VM1, etc are the names of the vms you would like to power on!

View solution in original post

0 Kudos
2 Replies
yboychev
Hot Shot
Hot Shot
Jump to solution

Hi,

You are not using correctly the data from the csv file. Whne you import a csv file the result is an array of PSCustomObject objects. So in order to make your script work you should modify it like this ...

foreach ($obj in $vmcsv) {

get-Vm $obj.vm | Start-Vm

}

\Yavor

PS I guess DR_VM1, etc are the names of the vms you would like to power on!

0 Kudos
Tigerstolly
Enthusiast
Enthusiast
Jump to solution

Thanks, thats just what i was looking for !

0 Kudos