A collection of PowerShell tools for creating and booting Windows VHD/VHDX virtual hard disks.
Caution
This comes with no support or warranty, if you mess up your BCD Store it can be difficult to get it working again without reinstalling. Use at your own risk
At the very least I recommend backing up your BCD store and saving it to a different drive than windows so you can boot to recovery and restore it if you need to
This project provides two main tools:
- CreateVHDX - Creates a bootable Windows VHDX from a Windows ISO, with automated setup via unattend.xml and winget package installation
- BootVHDX - Boots into an existing VHDX natively (without Hyper-V) using a one-time boot sequence
❓ Initially made this so I could install League of Legends without putting Riot Vanguard on my main windows install, and without messing with dual-boot and other weirdness, but it can easily be used for plently of other things.
Tip
For maximum isolation, encrypt all your other logical drives, storing the VHDX on it's own logical drive.
Creates a new VHDX file, installs Windows from an ISO, configures automated setup, and optionally creates a Hyper-V VM.
- Windows with Hyper-V PowerShell module (the script will enable it automatically if missing)
- Full Hyper-V platform only required if using
-VmNameto create a VM - Administrator privileges
- Windows 11 ISO file
# Create VHDX only (no VM) - works without full Hyper-V
.\CreateVHDX\CreateVHDX.ps1 -VhdPath "F:\VHDX\MyVM.vhdx" -VhdSizeGB 80 -IsoPath "C:\ISOs\Win11.iso" -SystemLabel "MyWin"
# Create VHDX and Hyper-V VM - requires full Hyper-V
.\CreateVHDX\CreateVHDX.ps1 -VhdPath "F:\VHDX\MyVM.vhdx" -VhdSizeGB 80 -IsoPath "C:\ISOs\Win11.iso" -VmName "MyVM" -SystemLabel "MyWin"| Parameter | Default | Description |
|---|---|---|
-VhdPath |
F:\VHDX\League.vhdx |
Path where the VHDX will be created |
-VhdSizeGB |
80 |
Size of the VHDX in GB (dynamic expansion) |
-IsoPath |
(required) | Path to Windows ISO file |
-VmName |
(optional) | Name for the Hyper-V VM (omit to skip VM creation) |
-SystemLabel |
LeagueWin |
Volume label for the Windows partition |
- Enables Hyper-V PowerShell module if not already available
- Creates a dynamic VHDX at the specified path
- Mounts and partitions the VHDX (MBR, NTFS, active partition)
- Applies Windows image from ISO using DISM
- Injects unattend.xml for automated OOBE setup
- Copies winget installation scripts to
C:\FirstTimeSetup\ - Installs BIOS boot files inside the VHDX
- (Optional If)
-VmNameis provided, creates a Generation 1 Hyper-V VM configured with:- 4 vCPUs
- Dynamic memory (2GB-8GB)
- Default Switch networking
unattend.xml
Automates Windows OOBE by:
- Skipping EULA, registration, and wireless setup screens
- Creating a local admin account (
LeagueUser) - Enabling auto-logon
Running winget package installation on first login
Note
Automatic winget-install currently doesn't run on first login but you can run it yourself from C:\FirstTimeSetup\winget-install.ps1
List of winget package IDs to install with winget-install.ps1 (one per line, # for comments):
Microsoft.WindowsTerminal
VideoLAN.VLC
Discord.Discord
# Add your packages here
winget-install.ps1
Script that reads winget-packages.txt and installs each package silently.
Boots into a VHDX natively on bare metal using Windows Boot Manager's one-time boot sequence feature.
- Windows with native VHD boot support (Win 10/11 should both work)
- Administrator privileges
- A bootable VHDX file
# Set up boot sequence (reboot manually later)
.\BootVHDX\boot-vhdx.ps1 -VhdPath "F:\VHDX\MyVM.vhdx"
# Set up and reboot immediately
.\BootVHDX\boot-vhdx.ps1 -VhdPath "F:\VHDX\MyVM.vhdx" -RebootNow| Parameter | Default | Description |
|---|---|---|
-VhdPath |
(required) | Path to the VHDX file to boot |
-Description |
Temp VHD Boot |
Description for the BCD entry |
-RebootNow |
$false |
Reboot immediately after configuration |
- Validates the VHDX is on a local filesystem (not network)
- Checks for existing BCD entry for this VHDX and reuses it if found
- Creates a new BCD entry by copying the current OS entry (if needed)
- Configures the entry to point to the VHDX
- Sets one-time boot sequence - next reboot boots into VHDX, subsequent reboots return to normal
Your default boot configuration remains unchanged. The VHDX boot entry is hidden from the boot menu and only used once per invocation of this script.
-
Create the VHDX only (for native boot):
.\CreateVHDX\CreateVHDX.ps1 -IsoPath "D:\Win11.iso" -VhdPath "F:\VHDX\Gaming.vhdx"
-
Or create VHDX with a Hyper-V VM:
.\CreateVHDX\CreateVHDX.ps1 -IsoPath "D:\Win11.iso" -VhdPath "F:\VHDX\Gaming.vhdx" -VmName "Gaming-VM"
-
Boot in Hyper-V for initial setup (if VM was created):
Start-VM "Gaming-VM"
-
Boot natively for better performance:
.\BootVHDX\boot-vhdx.ps1 -VhdPath "F:\VHDX\Gaming.vhdx" -RebootNow
-
Create a Shortcut for easy access
- Right-click > New > Shortcut
- Enter the following
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "Start-Process powershell -Verb RunAs -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File \"G:\Util\Scripts\boot-vhdx.ps1\" -VhdPath \"F:\VHDX\League.vhdx\" -RebootNow'"
Important
- Make sure to replace the file paths with yours (
-File \"G:\Util\Scripts\boot-vhdx.ps1\"-VhdPath \"F:\VHDX\League.vhdx\") - Quoting and escape sequences are important!