I'm trying to clone a list of VM's to an alternate datastore, I have a list of VM's in a .CSV file.
## Connect-VIServer vcenter.server
$VMHost = "hostname.test"
$srcvms = Import-Csv -Path ./Documents/vmnames.csv -UseCulture | select -ExpandProperty VM
Foreach ($srcvm in $srcvms) {
new-vm -name "clone_$srcvm" -VM $srcvm -VMHost $VMHost -Datastore "test" -DiskStorageFormat Thin -RunAsync
}
My variable returns hostname.test, I am connected to my vCenter, but it's barking about the $VMhost variable..
new-vm -name "clone_$srcvm" -VM $srcvm -VMHost '$VMHost'
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| 5/9/2022 12:52:48 PM New-VM Please specify at least one of the following parameters: "ResourcePool" or "VMHost".
All the hosts have the test datastore mounted, can I forego the VMhost requirement or what am I doing wrong?
Thanks,
Greg