I recently formatted my PC and started using Virtual Machines heavily for various workloads. Why?

  • I don’t want to bloat my PC with one-off trial software
  • I want to run in more modular manner; a VM dedicated for development, a VM for server stuff, a VM for banking, one for 3D printing, one just to try shit out & throw it away immediately.
  • I do risky stuff (investigate malware, defuse email bombs, etc.)

Therefore, I need to be able to create these quickly and painlessly. Enter my Powershell script. Right-click –> Run with PowerShell, enter a VM name, type “U” for Ubuntu, “D” for Desktop (Windows), or “S” for Server (Windows). That’s it. Done. Here it is in action:

How does this work? The simplicity lies in the hidden complexity, which isn’t all that complex.

  1. I created 3 Virtual Machines: Ubuntu (20.04.3), Windows 11 Pro, and Windows Server 2022. I ran updates on each OS, created user accounts, installed software that I use on every machine (Notepad++ on Windows, Terminator on Linux, Firefox on all, etc.)
  2. Once completed, I shut them down, deleted the Virtual Machine (but kept the Virtual Hard Disk), and marked the vhdx as “Read Only”.
  3. From there I created the PowerShell script to reference those “Parent” disks, and each new VM will create a differencing disk based off the appropriate parent. This keeps disk usage to a minimum.
    Each VM gets:
    1. 4GB memory (Dynamic)
    2. 4 vCPU
    3. Set to “Generation 2”
    4. Checkpoints disabled.
    5. Guest Services enabled
    6. If Ubuntu is selected, SecureBoot is disabled and Enhanced Session is enabled.

With all this in place, I can spin up a VM at-will with no real concern for disk usage, no (further) setup required, and I can throw it away without batting an eye. My 12 year-old wants to browse the web and click on all the things? You get a VM. I want to try out some open source CAD software? You get a VM. Extract malware out of a memory dump? You get…the picture.

With a couple quick edits to the script, you can point it at your own base images, add your own operating systems, and customize your VM settings as you wish. Enjoy!