Gadgets
How to Create VMs from VM Templates in vCenter (2 Methods)
[ad_1]
Read this guide to learn how to create a VM from a template from vCenter web client or with VMWare PowerCLI PowerShell commands.
Option 1: Create a VM with vCenter Web Client
- Sign in to vCenter web client. Select the ESXi host or cluster with the VM Template you want to use to create a VM, then click the VM Templates tab.
If you’re not sure of the location of the VM template, search for it.

- Then, right-click the VM template and select “Create VM from Template.”


- Give the VM a name.


- Then, select the host or cluster to create the VM – vCenter will preform compactibility test. On the next page, select a datastore.




- On this page, if you wish to customize the OS or the VM’s hardware, check the relevant checboxes.


- Finally, review your selections and create the VM.


Option 2: Create a VM in vCenter with PowerShell
To run the PowerShell commans discussed in this section, you must install VMWare PowerShell module. Read Install VMWare PowerCLI Module PowerShell Module for the steps.
- Connect to your vCenter Server by running this command.
Change ipmvcsa.corp.itechguides.com to your vCenter Server URL and corpadministrator to an account with the permission to create VMs on the vCenter server.
Connect-VIServer -Server ipmvcsa.corp.itechguides.com -Credential (Get-Credential corpadministrator)
When you run the command, PowerShell will request the password for the account. Enter the password and click OK.


- Once you connect to the vCenter server, run the following commands. I have included a comment (comments starts with #) before each command to explain what it does.
#Save the name of the vCenter datacenter in a variable
$Datacenter = "IPMdCenter1"#Save the name of the VM template in a variable
$VMTemplatename = "Win2022srv-template"#Get the VM Template from vCenter
$VMTemplate = Get-Datacenter $Datacenter | Get-Template $VMTemplatename#Save the datastore name in a variable
$Datastore = "ipmpvmw3-datastore-1"#Save the new VM's name in a variable
$VMName = "IPMvS20222"#Save the name of the EXSi host in vCenter to create the VM
$VMHost = "ipmpvmw3.corp.itechguides.com"
- Finally, using the information from 3, create a new VM with the New-VM command.
New-VM -Name $VMName -Template $VMTemplate -Host $VMHost -DataStore $Datastore -DiskStorageFormat Thin -Confirm:$false
The New-VM command takes a while to complete. While the VM is creating, PowerShell displays a progress bar.


Once the VM is created, PowerShell displays the name, state, number of CPUs and RAM size.


You can also return these values with the Get-VM command.
Get-VM -Name $VMName


Conclusion
Creating VMs with pre-cpnfigured vCenter VM templates provides a consistent way to create VMs. Beyond consistency, it also makes creating VMs faster.
I have shown how to perform this common VMWAre admin task using the web client and PowerShell. The PowerShell method is helpful if you’re automating the process.
I have a PowerShell script that automates creating VMs, installing all required apps, and install Windows Updates, pretty amazing stuff!
I hope I made your day with this guide. Let me know your thoughts by responding to “Was this page helpful?” below.
[ad_2]
Victor Ashiedu
Source link
