Created
February 25, 2022 18:27
-
-
Save ttlequals0/6a80c29432d327c4b47b8f46dbeaeb55 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Specify vCenter Server, vCenter Server username and vCenter Server user password | |
$vCenter="" | |
# | |
# Specify number of VMs you want to create | |
$vm_count = "33" | |
# | |
# Specify the VM you want to clone | |
$clone = "" | |
# | |
# | |
# Specify the datastore or datastore cluster placement | |
$ds = "" | |
# | |
# Specify vCenter Server Virtual Machine & Templates folder | |
$Folder = "" | |
# | |
# Specify the vSphere Cluster | |
$Cluster = "" | |
# | |
# Specify the VM name to the left of the - sign | |
$VM_prefix = "" | |
# | |
# End of user input parameters | |
#_______________________________________________________ | |
# | |
write-host "Connecting to vCenter Server $vCenter" -foreground green | |
Connect-viserver $vCenter -WarningAction 0 | |
1..$vm_count | foreach { | |
$y="{0:D2}" -f $_ | |
$VM_name= $VM_prefix + $y | |
$ESXi=Get-Cluster $Cluster | Get-VMHost -state connected | Get-Random | |
write-host "Creation of VM $VM_name initiated" -foreground green | |
New-VM -Name $VM_Name -VM $clone -VMHost $ESXi -Datastore $ds -Location $Folder -RunAsync | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment