filmov
tv
Creating multiple VM in Vmware ESX using vSphere PowerCLI
Показать описание
Tested on an old server HP Proliant DL360 and the calculated maximum running vm are set to 30, to walkaround it run the following command in ssh shell "esxcli system settings kernel set -s maxVCPUsPerCore -v 512" , where 512 is the amount of max VMs per CORE.
-------------------------------
Script used :
Add-PSSnapin VMware.VimAutomation.Core
# Specify vCenter Server, vCenter Server username and vCenter Server user password
$vCenter=”10.13.24.30“
$vCenterUser=”root“
$vCenterUserPassword=”Passw0rd“
#
# Specify number of VMs you want to create
$vm_count = “500“
#
# Specify number of VM CPUs
$numcpu = “1“
#
# Specify number of VM MB RAM
$MBram = “16“
#
# Specify VM disk size (in MB)
$MBguestdisk = “4“
#
# Specify VM disk type, available options are Thin, Thick, EagerZeroedThick
$Typeguestdisk =”Thin“
#
# Specify VM guest OS
$guestOS = “winNetStandardGuest“
#
# Specify vCenter Server datastore
$ds = “datastore1“
#
# Specify the vSphere Cluster
$Cluster = “10.13.24.30“
#
# Specify the VM name to the left of the – sign
$VM_prefix = “VM-“
#
# End of user input parameters
#_______________________________________________________
#
write-host “Connecting to vCenter Server $vCenter” -foreground green
Connect-viserver $vCenter -user $vCenterUser -password $vCenterUserPassword -WarningAction 0
1..$vm_count | foreach {
$y=”{0:D2}” -f $_
$VM_name= $VM_prefix + $y
$ESXi=Get-VMHost -state connected | Get-Random
write-host “Creation of VM $VM_name initiated” -foreground green
New-VM -Name $VM_Name -VMHost $ESXi -numcpu $numcpu -MemoryMB $MBram -DiskMB $MBguestdisk -DiskStorageFormat $Typeguestdisk -Datastore $ds -GuestId $guestOS
write-host “Power On of the VM $VM_name initiated” -foreground green
Start-VM -VM $VM_name -confirm:$false -RunAsync
}
-------------------------------
Script used :
Add-PSSnapin VMware.VimAutomation.Core
# Specify vCenter Server, vCenter Server username and vCenter Server user password
$vCenter=”10.13.24.30“
$vCenterUser=”root“
$vCenterUserPassword=”Passw0rd“
#
# Specify number of VMs you want to create
$vm_count = “500“
#
# Specify number of VM CPUs
$numcpu = “1“
#
# Specify number of VM MB RAM
$MBram = “16“
#
# Specify VM disk size (in MB)
$MBguestdisk = “4“
#
# Specify VM disk type, available options are Thin, Thick, EagerZeroedThick
$Typeguestdisk =”Thin“
#
# Specify VM guest OS
$guestOS = “winNetStandardGuest“
#
# Specify vCenter Server datastore
$ds = “datastore1“
#
# Specify the vSphere Cluster
$Cluster = “10.13.24.30“
#
# Specify the VM name to the left of the – sign
$VM_prefix = “VM-“
#
# End of user input parameters
#_______________________________________________________
#
write-host “Connecting to vCenter Server $vCenter” -foreground green
Connect-viserver $vCenter -user $vCenterUser -password $vCenterUserPassword -WarningAction 0
1..$vm_count | foreach {
$y=”{0:D2}” -f $_
$VM_name= $VM_prefix + $y
$ESXi=Get-VMHost -state connected | Get-Random
write-host “Creation of VM $VM_name initiated” -foreground green
New-VM -Name $VM_Name -VMHost $ESXi -numcpu $numcpu -MemoryMB $MBram -DiskMB $MBguestdisk -DiskStorageFormat $Typeguestdisk -Datastore $ds -GuestId $guestOS
write-host “Power On of the VM $VM_name initiated” -foreground green
Start-VM -VM $VM_name -confirm:$false -RunAsync
}
Комментарии