Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 144140

Cloning VM to a separate datacenter

$
0
0

Hey guys,

 

I currently have two ESX servers that are clustered, but the datastores aren't connected to each other.  When I clone a VM in the viClient interface, I can choose to clone it to the other datastore on the other host and everything works fine.

 

I'm currently trying to write a PowerCLI script that allows me to clone a VM and I'd like to be able to specify which host/datastore it gets put on.  Here is the script as it stands:

 

$vms = Import-CSV C:\scripts\test.csv
foreach ($vm in $vms) {     New-VM -VM $vm.sourcevm -Name $vm.name -VMHost $vm.host -Datastore $vm.datastore -LinkedClone -ReferenceSnapshot $vm.snapshot 
-OSCustomizationSpec $vm.customization
}

 

This script works fine as long as -VMHost and -Datastore are the same as the source VM, but I'd like to be able to clone a VM to my second host/datastore.  If I change -VMHost and -Datastore to my other host/datastore, I get the following error:

 

New-VM The operation for the entity VirtualMachine-vm-479 failed with the following message: "Virtual disk 'Hard disk 1' is not accessible on the host: Unable to access file [datastore2] Windows7/Windows7.vmdk"

 

Note: For the example above, the VM is contained on host2/datastore2 and I've entered host1/datastore1 for my VMHost/Datastore.

 

Any information you could provide would be greatly appreciated!


Viewing all articles
Browse latest Browse all 144140

Trending Articles