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

Re: PowerCLI script - New VM from template

$
0
0

I would like to pose a question along the same lines as this original question hopefully answering both questions.

 

So I have two datacenters with a template in one that I want to clone to the other. The issue is I use the New-Template command and for the -Location I put the DC name or a variable such as the below $dc with identifies the same DC name. If I specify the folder I want it to go to instead of the DC with -Location it states it can only copy a template on the same DC. If I just put the DC in the location it copies to the appropriate Datacenter but drops the clone in the root of the DC. I want to be able to use the New-Template command to not only clone the template to a new template on a different DC but in the same command I want to tell it to go to the appropriate folder in that datacenter. Sorry if this is confusing.

 

Manually in vSphere I can easily accomplish this through the interface, its through CLI that it has been tricky. Trying to automate the process basically this is the only hurdle I am running into. I can Move-item easily enough I would just like to wrap it all up if possible in the New-Template command..

 

My command looks basically like this:

 

Template is in DC2

 

 

$dc = Get-Datacenter DC1

$folder = Get-Folder -Name "~INT dc2 to dc1 clone staging" -Location $dc

$Temp = "TemplateName"

$ds = "DS Name"

$vmhost = "VM Host Name"

 

New-Template -Template $Temp -Name "New Template Name" -Location $folder -VMHost $vmhost -Datastore $ds -DiskStorageFormat Thin -Confirm:$false

 

I think it's just a redefined variable statement that will let the New-Template command know that the template needs to go to the DC1 as well as go to the Folder in DC1. Just not sure how to contruct it.


Viewing all articles
Browse latest Browse all 232869

Trending Articles