Power shell create VM VMWARE vcenter
Vytvorenie VM pomocou powershell. (Pre správnu funkčnosť je potrebne sa pripojiť na vcenter server. https://blog.mhasin.eu/?p=764)
Deploy zo šablóny:
# Specify vCenter Server datastore
$ds = “SST3_1“
#
# Specify the vSphere Cluster
$Cluster = “L9“
#
# Specify the VM name to the left of the – sign
$VM_prefix = “VM-“
$OSSpecs = Get-OSCustomizationSpec -Name 'windows'
$VMTemplate = Get-Template -Name 'windows'
#Get Cluster
$cluster = Get-Cluster -Name $Cluster
# Get a host within cluster
$VM_name= $VM_prefix
$ESXi = Get-Cluster $cluster | Get-VMHost | Get-Random
write-host “Creation of VM $VM_name initiated” -foreground green
New-VM -Name $VM_Name -Template $VMTemplate -OSCustomizationSpec $OSSpec -VMHost $ESXi -Datastore $ds | Start-VM
- $VMTemplate = Get-Template -Name ‚windows‘ – Definícia šablony vo vcenter
- $OSSpecs = Get-OSCustomizationSpec -Name ‚windows‘ – Definovanie customization profilu
- $ESXi = Get-Cluster $cluster | Get-VMHost | Get-Random – výber náhodného hosta z daného klastra
Zapnutie VM:
Start-VM -VM $VM_name -confirm:$false -RunAsync