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 !
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!
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!
Thanks, thats just what i was looking for !