Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $VMLocation = "C:\VHDs\MDTCapturedVMs\Win10"
- $VMISO = "\\MDT01\Ref10$\Boot\RefWin10x64.iso"
- $VMNetwork = "Teamed Switch"
- # Create REF001
- $VMName = "REF001"
- $VMMemory = 4096MB
- $VMDiskSize = 40GB
- New-VM -Name $VMName -BootDevice CD -MemoryStartupBytes $VMMemory -SwitchName $VMNetwork -Path $VMLocation -NoVHD -Verbose -Generation 1
- Set-VMProcessor –VMName $VMName –Count 4
- New-VHD -Path "$VMLocation\$VMName\Virtual Hard Disks\$VMName-Disk1.vhdx" -SizeBytes $VMDiskSize -Verbose
- Add-VMHardDiskDrive -VMName $VMName -Path "$VMLocation\$VMName\Virtual Hard Disks\$VMName-Disk1.vhdx" -Verbose
- Set-VMDvdDrive -VMName $VMName -Path $VMISO -Verbose
- Start-VM -VMName $VMName
- $VM = Get-VM -Name $VMName
- while ($VM.State -ne "off")
- {
- write-host "The VM is still running"
- sleep 20
- }
- Remove-VM -Name $VMName -Force
- Remove-Item -Recurse -Force $VMLocation\$VMName
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement