This script will provision a 4GB Ram, 40 GB HD Server 2008 R2 VM, set the CD to an OSD iso, set the BootDelay to 5 seconds, and start the machine
$vmhost = Get-VMHost "server.name.local" $ds = Get-Datastore "server:storage1" $rp = get-resourcepool -id "ResourcePool-resgroup-22" $nn = "NetworkName" $gi = "windows7Server64Guest" $iso = "[server:ISOs] Folder/OSD.iso" #### $vmname = "VMGeust01" New-VM -name $vmname -VMHost $vmhost -numcpu 1 -DiskMB 40960 -memoryMB 4096 -datastore $ds -guestID $gi -resourcepool $rp -cd -NetworkName $nn Get-VM $vmname | 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
Comments are closed.