This week I was doing a ConfigMgr 2012 R2 class in New York, and one of students asked if he could get the script I used to create the VM I use to build my reference images. Sure, here it is:
$VMLocation = "C:\VMs"
$VMISO = "C:\ISO\MDT Build Lab x86.iso"
$VMNetwork = "Internal"
# Create REF001
$VMName = "REF001"
$VMMemory = 4096MB
$VMDiskSize = 60GB
New-VM -Name $VMName -BootDevice CD -MemoryStartupBytes $VMMemory -SwitchName $VMNetwork -Path $VMLocation -NoVHD -Verbose
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-VMProcessor -VMName $VMName -Count 2
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
Happy Deployment,
/ Johan
Is it possible to create convert the ISO to vhdx? so that I can attached the vhdx to the VM and boot from there? its like having a prestage media, but allowing me to change the preferred AdvertID dynamically.
Yes, but you have to extract the ISO to a folder first, and then apply the install.wim to a VHDX, or any other WIM image that you have. Check out the https://github.com/DeploymentResearch/DRFiles/blob/master/Scripts/AutoPilot/Export-Windows11EnterpriseWIMFromISO.ps1 and https://github.com/DeploymentResearch/DRFiles/blob/master/Scripts/AutoPilot/Convert-WindowsImage-Syntax.ps1 scripts
Using with the latest version of MECM and I wanted to try creating a prestaged‑media workflow described in the article: https://techcommunity.microsoft.com/blog/coreinfrastructureandsecurityblog/osd-pre-stage-and-uefi-systems/323064 My objective is to: 1. Use MECM to create prestaged media, which outputs a prestage.wim file. 2. Convert that prestage.wim into a bootable VHDX that contains the MECM WinPE boot image. 3. Create a new Hyper‑V VM and attach the VHDX. 4. Boot the VM into WinPE and access the full list of available task sequences, rather than being limited to the single task sequence embedded in the prestaged media. Hence, I could select and deploy any TS with… Read more »
The prestage media scenario is still supported in the latest version of ConfigMgr (2509 as of now). I used it quite recently in a project. ConfigMgr still allow you to select any available task sequences, but I wouldn't recommend picking one with a different OS image. You can also override with a prestart command and the SMSTSPreferredAdvertID variable. That being said, some of our customers are instead using roles, and prompting for a role selection, to make a single TS behave differently.