Quick and Dirty Scripting

A blog that focuses on automating system administration tasks for Linux, Windows, and VMware ESX

Wednesday, November 14, 2007

 

Creating a VM from a Template using Powershell

Yesterday, I posted that I was having issues creating a new VM from a template while using VMware's Powershell commands. It must have been the weather or something because today, it seems to be working without any issues. The following is how you can create a new VM from a template using Powershell. I did notice one interesting thing that I want to ask VMware about which I will mention at the end of this entry.

PS C:\Temp> $vc = Get-VIServer "vc.example.com"
There were one or more problems with the server certificate:

* The certificate's CN name does not match the passed value.

PS C:\Temp> $t = Get-Template -Server $vc
PS C:\Temp> $t[0]

Name Id
---- --
ESX3-WIN2K3SP2-ST... VirtualMachine-vm-23637

PS C:\Temp> $esx = Get-VMHost -Name "esx1.example.com"
PS C:\Temp> $esx

Name Id
---- --
esx1.example.com HostSystem-host-7523

PS C:\Temp> New-VM -Host $esx -Template $t[0]

cmdlet New-VM at command pipeline position 1
Supply values for the following parameters:
Name: vm-1

At this point, a Powershell progress bar appears and the progress of the deployment can be tracked.
The shell's focus is not returned until after the deployment is complete. The interesting thing is, that I can CTRL-C and cancel this Powershell command but the template continues to be deployed from within VirtualCenter. I am not sure how VMware will handle this situation but I would expect the deployment to be canceled once I cancel the Powershell command. I would love to hear any one else's thoughts on this matter as well.

Labels:


Comments: Post a Comment





<< Home

Archives

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]