So here is the scenario:
Within my vcenter there are two datacenters. In one (B)Datacenter we have our development systems and the other (A)Datacenter are our production environments. We often have to take a clone of a (B)VM and clone it over to an (A)VM. We have a method process that we use to move our VMs. I am trying to powerCLI the whole process in order to save on some manual cloning time. Below is our process:
1. Clone a live (B)VM and take it from the (B)Datacenter under the "DEV" Folder, under that is a subfolder "AppServer" where the vm "DevAPP" exists and clone it from that subfolder to another subfolder also in "AppServer" called "~DEV (B) to (A) Clone Staging".
2. Once the clone "DevApp_today's date" is completed in the "~DEV (B) to (A) Clone Staging" we remove the network adapter 1 from it and then convert it to a template.
3. Once it is converted to a template with the name "DevApp_today's date" we clone it over from the (B)Datacenter folder "~DEV (B) to (A) Clone Staging" to (A)Datacenter folder "(B) to (A) Clone Staging".
4. Once the Template "DevApp_today's date" is in the (A) Datacenter we convert it back to a VM and and add the network adapter back to it, set it to the appropriate VLAN and then enable connected at power on.
5. Once the Network Adpater is back on the VM we then convert it back to a Template and deploy 11 VMs from it with customization files to configure the VM.
For the most part steps 1 and 2 I can script fairly easily, as well as 4 and 5, my biggest problem is the step 3. What I have been trying is using the New-Template command.
Example: New-Template -Template "DevApp_today's date" -Location A(Datacenter Name) -VMHost $HostA(a host in the A Datacenter) -Datastore $Data(a storage in the A Datacenter) -DiskStorageFormat Thin -RunAsync -Confirm:$false
This works to get the Template from (B)Datacenter to (A)Datacenter but it drops it in the root of the (A)Datacenter. I know this is because in -Location I put "A" there however I don't know anyway to break it down from there to drill down to the subfolders of (A)Datacenter. If I put the subfolder (A) "(B) to (A) Clone Staging" it just makes a stink about how I already have a Template by that name and it must be cloned across the same datacenter. In the meantime once it reaches the root of (A) I just run a Move-Inventory on the Template to move it to "(B) to (A) Clone Staging".
I don't necessarily need a whole script created for me, I just want to know how to move the template from (B) to (A) without it needing to be dropped in Root (A) and then Move-Inventory