title: Booting from an ISO image using PowerCLI scripts
body: <p>How do I make the following script work? Currently I am able to create a new virtual machine in my server. I wish to also load the Windows ISO image and do an unattended installation in the virtual machine. How shall I edit the script to make this work?</p>
  
  <pre><code># Virtual Center Details
  $server_address = "xxxxx"
  $username = "xxxxx"
  $password = "xxxxx"
  $iso = "WINXP_X86_SP3_CD.ISO"
  
  Get-VIServer -Server $server_address -Protocol https -User $username -Password $password
  
  foreach ($vmm in $array)
  {
      $vmm = "VirtualMachine"
  
      New-VM -name $vmm -DiskMB 20000 -memoryMB 2000
      Get-VM $vmm | Get-CDDrive | Set-CDDrive -IsoPath $iso -StartConnected $true -Confirm:$false
      $value = "5000"
      $vm = Get-VM $vmname | Get-View
      $vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
      $vmConfigSpec.BootOptions = New-Object VMware.Vim.VirtualMachineBootOptions
      $vmConfigSpec.BootOptions.BootDelay = $value
      $vm.ReconfigVM_Task($vmConfigSpec)
  
      Start-vm -vm $vmname
  }
  </code></pre>