# Define variables
$vcenterServer = "your_vcenter_server"
$username = "your_username"
$password = "your_password"
$clusterName = "your_cluster_name"
$datastoreName = "your_datastore_name"
$vmFolder = "your_vm_folder"
$vmNames = @("VM1", "VM2", "VM3") # Array of VM names
$isoPaths = @("path/to/iso1.iso", "path/to/iso2.iso", "path/to/iso3.iso") # Array of ISO file paths
$guestOS = "Windows Server 2022" # Guest OS for all VMs
$memoryMB = 2048 # Memory assigned to all VMs
$cpuCount = 1 # Number of CPUs assigned to all VMs
$diskSizeGB = 40 # Size of the hard disk for all VMs

# Connect to vCenter Server
Connect-VIServer -Server $vcenterServer -User $username -Password $password

# Get the cluster object
$cluster = Get-Cluster -Name $clusterName

# Get the datastore object
$datastore = Get-Datastore -Name $datastoreName

# Get the VM folder object
$vmFolder = Get-Folder -Path $vmFolder

# Loop through each VM name and ISO
foreach ($vmName, $isoPath in @($vmNames, $isoPaths)) {
# Create a new VM
$vm = New-VM -Name $vmName -Cluster $cluster -Datastore $datastore -Path $vmFolder -GuestOS $guestOS

# Set VM memory and CPU
$vm.ResourceAllocation.Memory = $memoryMB * 1024 * 1024
$vm.ResourceAllocation.CpuAllocation.Reservation = $cpuCount
$vm.ResourceAllocation.CpuAllocation.Limit = $cpuCount

# Add a hard disk
$disk = New-HardDisk -VM $vm -CapacityGB $diskSizeGB

# Add CD/DVD drive and connect ISO
$cdrom = New-CDDrive -VM $vm -IsoPath $isoPath -StartConnected

# Power on the VM
Start-VM -VM $vm
}

# Disconnect from vCenter Server
Disconnect-VIServer


# Note:
* This script is a basic example and may need modifications depending on your specific environment.
* Make sure you have the necessary permissions to perform these actions in vCenter Server.
* You can customize the script by adding additional parameters for VM configuration, such as network settings, NICs, etc.

I hope this helps! Let me know if you have any other questions.

Podcast also available on PocketCasts, SoundCloud, Spotify, Google Podcasts, Apple Podcasts, and RSS.

Leave a comment

The Podcast

Join Naomi Ellis as she dives into the extraordinary lives that shaped history. Her warmth and insight turn complex biographies into relatable stories that inspire and educate.

About the podcast