I got new hardware for my lab today and needed to install Server 2016 Hyper-V on it. I also don't have any burnable DVD's or Blu-Rays lying around. I needed to be able to install Windows via a USB thumb drive and I didn't want to use anything other than what comes with Windows. I used PowerShell for almost all of this. Most guides I found involved downloading some random imaging tool and I didn't want to do that, I wanted to use plain old Windows, here's a guide to do just that.

The primary steps to do this are:

  1. Download the ISO containing the version of Windows to install. You can use a disk you already have if you want, you will need to copy the files from that instead of mounting an iso, and copying files from that iso, then dismounting the iso, to just copying from the disk.
  2. While the ISO is downloading, find a thumb drive. I used a 16gb one, but a 4gig should be big enough for the Hyper-V install.
  3. Format the thumb drive and make the partition bootable. I used PowerShell for everything that I could.
  4. Copy the contents of the ISO onto the USB drive.

The reason I chose 2016 over 2019 Hyper-V is that at the time of this writing 2019 Hyper-V was not available. They had 2019 Standard and Datacenter, but not the Hyper-V only version. Another thing, while I was anxiously awaiting it to be re-released I was also seeing a lot of reports that if your BIOS was configured for UEFI chances were pretty good that it would blue screen the first time you booted a VM. It looks like the solution to that problem is disable UEFI and install the OS in regular BIOS mode. Unfortunately, my RAID card requires UEFI to be able to boot from any of the disks.

Anyways, here's step by step instructions on making the bootable thumb drive. In theory, this should work for most versions of Windows.

Download the ISO

You need the ISO from Microsoft. So head over to Microsoft.com and get the ISO. If you already have an install DVD then you can use that, we're just going to copy the files off it.

If you are downloading the ISO, you can do the next few steps (finding the thumb drive and preparing it) while it downloads

Find the thumb drive

The file content size for 2016 Hyper-V is 2.66 gig at the time of writing, so you will need at a minimum that size. You will need at least a 4gig thumb drive.

Prepare the thumb drive

  1. Put the thumb drive in your computer.

  2. Copy anything on it that you want to keep. We will be completely wiping the drive.

  3. Run PowerShell as administrator.

  4. Using PowerShell, we need to get the thumb drive that we want to put the install on.

    1. Get a list of the disks
      get-disk | select FriendlyName, SerialNumber, AllocatedSize
      
      This should return a table like the following
      FriendlyName        SerialNumber         AllocatedSize
      ------------        ------------         -------------
      Intel Raid 1 Volume MyDrive              1000202043392
      SanDisk Ultra       2005194212117592EC29   16008609792       
      
    2. Using the serial number from the table corresponding to your thumb drive, run the following
      $disk = get-disk -serialnumber 2005194212117592EC29
      
  5. Verify you got the correct disk

    $disk | select *
    

    This should return something like the following

    DiskNumber            : 1
    PartitionStyle        : MBR
    ProvisioningType      : Fixed
    OperationalStatus     : Online
    HealthStatus          : Healthy
    BusType               : USB
    UniqueIdFormat        : Vendor Specific
    OfflineReason         :
    ObjectId              : {1}\\DESKTOP\root/Microsoft/Windows/Storage/Providers_v2\WSP_Disk.ObjectId="{91780803-7646-11e8-9284-806e6f6e6963}:DI:\\
                            ?\usbstor#disk&ven_sandisk&prod_ultra&rev_2.01#2005194212117592ec29&0#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}"
    PassThroughClass      :
    PassThroughIds        :
    PassThroughNamespace  :
    PassThroughServer     :
    UniqueId              : USBSTOR\DISK&VEN_SANDISK&PROD_ULTRA&REV_2.01\2005194212117592EC29&0:desktop
    AdapterSerialNumber   :
    AllocatedSize         : 16008609792
    BootFromDisk          : False
    FirmwareVersion       : 2.01
    FriendlyName          : SanDisk Ultra
    Guid                  :
    IsBoot                : False
    IsClustered           : False
    IsHighlyAvailable     : False
    IsOffline             : False
    IsReadOnly            : False
    IsScaleOut            : False
    IsSystem              : False
    LargestFreeExtent     : 0
    Location              : Integrated : Adapter 0 : Port 0
    LogicalSectorSize     : 512
    Manufacturer          : SanDisk
    Model                 : Ultra
    Number                : 1
    NumberOfPartitions    : 1
    Path                  : \\?\usbstor#disk&ven_sandisk&prod_ultra&rev_2.01#2005194212117592ec29&0#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}
    PhysicalSectorSize    : 512
    SerialNumber          : 2005194212117592EC29
    Signature             : 1730715549
    Size                  : 16008609792
    PSComputerName        :
    CimClass              : ROOT/Microsoft/Windows/Storage:MSFT_Disk
    CimInstanceProperties : {ObjectId, PassThroughClass, PassThroughIds, PassThroughNamespace...}
    CimSystemProperties   : Microsoft.Management.Infrastructure.CimSystemProperties
    
  6. Remove all partitions from the thumb drive
    DANGER: THIS IS A DESTRUCTIVE OPERATION; ALL DATA WILL BE REMOVED FROM THE SELECTED DISK

    Clear-Disk -Number $disk.Number -RemoveData -RemoveOEM -Confirm:$false
    
  7. Initialize the thumb drive, making sure it is using MBR as the partition type.

    Initialize-Disk -Number $disk.Number -PartitionStyle MBR
    
  8. Create a new partition on the thumb drive

    $part = New-Partition -DiskNumber $disk.Number -UseMaximumSize -IsActive
    
  9. Format the partition

    Format-Volume -Partition $part -FileSystem FAT32
    

    For some OS's you may need to use NTFS, however, some BIOS's out there won't boot from a drive with NTFS so I'm defaulting to FAT32. You will know if you need to use NTFS when you copy the files because it will complain about one of the files being too big to copy or the parameters is incorrect. In which case, start from the step about clearing the disk and change FAT32 to NTFS

  10. Assign a drive letter so we can make it bootable using bootsect.exe

    Add-PartitionAccessPath -DiskNumber $disk.Number -PartitionNumber $part.PartitionNumber -AssignDriveLetter
    $part = Get-Partition -DiskNumber $disk.Number -PartitionNumber $part.PartitionNumber
    $driveLetter = ($part.AccessPaths | % { if ($_[1] -eq ":") { $_ } }).Trim("\")
    
  11. Make the thumb drive bootable

    bootsect.exe /nt60 $driveLetter
    

Copy the files to the thumb drive

  1. Mount the ISO
    Mount-DiskImage <<DISK IMAGE FILE NAME>>
    $image = Get-DiskImage <<DISK IMAGE FILE NAME>>
    $rootPath = $image.DevicePath + "\"
    
  2. Copy the files from the disk image
    # Create a drive object (needed because of the UNC issue in copy-item)
    $psdrive = New-PSDrive -Name isosource -Root $rootPath -PSProvider FileSystem
    # Recursively copy the files
    Copy-Item -Path isosource:\* -Destination $driveLetter -Recurse -Verbose
    # Delete the drive object
    Remove-PSDrive isosource
    
  3. Unmount the ISO
    Dismount-DiskImage <<DISK IMAGE FILE NAME>>
    

And that's it. You should now have a bootable USB drive for installing Windows.

Disclaimer: I am not responsible for any data loss of any kind. It is your sole responsibility to make backups of data on your thumb drive before following these directions. It is also your sole responsibility for making sure that you are erasing the correct drive and that the above PowerShell commands are correct for your system.