Advertisement
Guest User

Untitled

a guest
Jan 21st, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $VMLocation = "C:\VHDs\MDTCapturedVMs\Win10"
  2. $VMISO = "\\MDT01\Ref10$\Boot\RefWin10x64.iso"
  3. $VMNetwork = "Teamed Switch"
  4.  
  5. # Create REF001
  6. $VMName = "REF001"
  7. $VMMemory = 4096MB
  8. $VMDiskSize = 40GB
  9. New-VM -Name $VMName -BootDevice CD -MemoryStartupBytes $VMMemory -SwitchName $VMNetwork -Path $VMLocation -NoVHD -Verbose -Generation 1
  10. Set-VMProcessor –VMName $VMName –Count 4
  11. New-VHD -Path "$VMLocation\$VMName\Virtual Hard Disks\$VMName-Disk1.vhdx" -SizeBytes $VMDiskSize -Verbose
  12. Add-VMHardDiskDrive -VMName $VMName -Path "$VMLocation\$VMName\Virtual Hard Disks\$VMName-Disk1.vhdx" -Verbose
  13. Set-VMDvdDrive -VMName $VMName -Path $VMISO -Verbose
  14. Start-VM -VMName $VMName
  15.  
  16. $VM = Get-VM -Name $VMName
  17. while ($VM.State -ne "off")
  18. {
  19.     write-host "The VM is still running"
  20.     sleep 20
  21. }
  22.  
  23. Remove-VM -Name $VMName -Force
  24. Remove-Item -Recurse -Force $VMLocation\$VMName
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement