Hyper-V PowerShell generator
Generate the PowerShell to create a Hyper-V VM, build virtual switches or manage checkpoints — without memorising every parameter of New-VM and Set-VMProcessor. Pick the options and copy a ready-to-run script, with each cmdlet explained. Great companion to the CTF lab build. Generated entirely in your browser.
What this Hyper-V PowerShell generator does
Creating a Hyper-V VM in the GUI is fine for one machine, but the moment you want a repeatable, scriptable lab you switch to PowerShell. The trouble is that a complete VM build is not one cmdlet: it is New-VM for the shell, Set-VM and Set-VMProcessor for CPU and memory, Set-VMFirmware for Secure Boot and boot order, Add-VMDvdDrive for the install ISO, and finally Start-VM. This generator assembles that whole sequence from a few choices so you copy a script that runs top to bottom, and it explains what each line does.
It also covers the two other things you script constantly around a lab: the three virtual switch types (External, Internal, Private) that define your network isolation, and checkpoint management for clean revert points. These mirror the workflow in the CTF lab on Hyper-V walkthrough.
Why script Hyper-V instead of clicking
- Reproducibility. A script rebuilds the exact same VM after you blow one away, which you do constantly in a lab.
- Speed. Standing up five VMs is a loop, not twenty minutes of wizard clicks.
- Documentation. The script is the record of how the VM was built, version-controllable alongside the rest of your infrastructure.
- Consistency. Every lab VM gets the same Secure Boot, memory and switch settings, removing the “works on that VM only” class of problem.
The cmdlets behind a VM build
| Cmdlet | Role |
|---|---|
New-VM | Creates the VM, its generation, startup memory, a new or existing VHDX, and attaches a switch. |
Set-VM | Sets processor count and Dynamic Memory bounds after creation. |
Set-VMFirmware | Generation 2 only: toggles Secure Boot and sets the first boot device. |
Set-VMProcessor | Exposes virtualization extensions for nested virtualization. |
Add-VMDvdDrive | Attaches an install ISO so the VM can boot the installer. |
Start-VM / Checkpoint-VM | Powers the VM on; creates a named snapshot you can revert to. |
Virtual switches and isolation
The switch type decides what a VM can reach. An External switch bridges a physical NIC, giving VMs real network and Internet access. An Internal switch connects the VMs and the host but not the wider network. A Private switch connects VMs to each other only, with no host or Internet path, which is the safe place for anything you do not fully trust. The switch mode of this generator outputs all three so you can pick and adapt.
Privacy and how this tool runs
The script is built by JavaScript in your browser. No VM names, paths or settings are sent anywhere or logged. You can use the generator offline once the page has loaded.
Frequently asked questions
How do I create a Hyper-V VM in PowerShell?
Start with New-VM -Name "lab" -Generation 2 -MemoryStartupBytes 4GB -NewVHDPath "D:\VMs\lab.vhdx" -NewVHDSizeBytes 60GB -SwitchName "Internal", then set CPU with Set-VM -Name "lab" -ProcessorCount 2, adjust firmware with Set-VMFirmware, and finish with Start-VM. The generator assembles the whole sequence for you.
How do I disable Secure Boot for a Linux VM?
On a Generation 2 VM run Set-VMFirmware -VMName "lab" -EnableSecureBoot Off, or keep it on with the Linux template: -SecureBootTemplate MicrosoftUEFICertificateAuthority. Generation 1 VMs have no Secure Boot.
How do I enable nested virtualization?
With the VM off, run Set-VMProcessor -VMName "lab" -ExposeVirtualizationExtensions $true and disable Dynamic Memory for that VM. This lets you run Hyper-V, WSL2 or Docker inside the VM.
How do I create the three virtual switches?
New-VMSwitch -Name External -NetAdapterName "Ethernet" -AllowManagementOS $true for bridged, New-VMSwitch -Name Internal -SwitchType Internal for host-plus-VMs, and New-VMSwitch -Name Private -SwitchType Private for VM-only. Switch to the Virtual switches mode above to generate all three.
What is the difference between a standard and a production checkpoint?
A production checkpoint uses the guest VSS to make an application-consistent snapshot, like a backup. A standard checkpoint captures the full machine state including memory, which is ideal for a lab revert point but not for production data integrity. Set the type with Set-VM -CheckpointType.
How do I revert a VM to a checkpoint?
Get-VMSnapshot -VMName "lab" lists them, then Restore-VMSnapshot -VMName "lab" -Name "clean-baseline" -Confirm:$false reverts. Take a checkpoint right after a clean install so every experiment starts from the same baseline.













