One of the most basic things you will do within VMware infrastructure is creating virtual machines. Adding one new virtual machine like this is fine, but if you are going to create multi-VM it’s better to use script
Using New-VM
In PowerCLI, the New-VM cmdlet is used to create a new virtual machine. A few important things that can be set with New-VM are the following:
- VM name
- Host Name
- Size of hard disk
- Amount of memory
- Amount of vCpu
- VM template
- OSCustomizationspec
- Datastore location of disks
- Network settings
Here is an example of creating a VM :
after we connect to vCenter using “Connect-VIServer followed by vCenter Name ”
New-VM -Name 'Tlab01' -vmhost 'ESXI01.vSaiyan.info' -Datastore 'ISCSI_DS01' -NumCpu 4 -MemoryMB '2048' -DiskMB '40960' -NetworkName 'VM Netwrok'
another example of creating VM from Template and OS customization
New-VM -Name 'Tlab02' -vmhost 'ESXI01.vSaiyan.info' -Datastore 'ISCSI_DS01' -NumCpu 4 -MemoryMB '2048' -DiskMB '40960' -NetworkName 'VM Netwrok' -Template Temp_W2k12 -OSCustomizationSpec Cust_W2012R2
Deploy multiple VM’s from template with PowerCLI
1..5 | Foreach { New-vm -vmhost ESXI02.vSaiyan.info -Name Tlab0$_ -Template Temp_W2k12 -Datastore ISCSI_DS02 -OSCustomizationspec Cust_W2012R2}
this command will create 5 VMs with name Tlab01 to Tlab05
there are a lot of parameters you can use below some example of parameter you can use link
AlternateGuestName | Allows you to change the guest OS name. Only to be used when you use the parameter “otherGuest” or “otherGuest64”. |
CD | Add a CD drive to the guest or not |
Confirm | Whether the cmdlet should ask for confirmation |
Description | Adding a description in the notes field of a virtual machine |
DiskStorageFormat | Specify the virtual disk format Thin or Thick |
DrsAutomationLevel | Specifies the level of DRS automation applied to the virtual machine |
Floppy | Add a Floppy drive to the guest or not |
Version | Defines the hardware version the virtual machine will be using |
HAIsolationResponse | Indicate the HA response for the virtual machine in case of host isolation |
HARestartPriority | Specify the HA restart priority of the virtual machine in case a host fails |
Location | Folder placement of the virtual machine |
” The way to VMware PowerCLI” Series Posts :
2 thoughts on “The Way To PowerCLI : Creating Virtual Machines”
Comments are closed.