Use PowerShell to create a bootable USB drive from a Windows 10 or Windows Server 2016 ISO

It seems as if every time I need to reload a physical system, I’m searching the Internet to find a way to create a bootable USB drive from a Windows 10 or Windows Server 2016 ISO. I always seem to find tutorials that are using a process that’s almost 20 years old. They have me using the diskpart command line utility. Diskpart which initially shipped with Windows 2000, reminds me way too much of its predecessor, the fdisk command line utility.

The PowerShell commands in this blog article are written to be compatible with PowerShell version 4.0 and higher. Windows 8 or Windows Server 2012 with a GUI or higher is also required because although you can install PowerShell version 4.0+ on older operating systems, many of the commands used in this blog article won’t exist on them. This is due to the newer WMI namespaces which the cmdlets rely on not existing on older operating systems. Out-GridView which is used in this blog article isn’t supported on Server Core (Windows Server without a graphical user interface).

To create a bootable USB drive from an ISO, insert the USB drive into your computer and launch PowerShell as an administrator. Run the following PowerShell one-liner. Warning: This command will permanently delete all of the data on the selected USB drive. Proceed at your own risk. You’ve been warned.

Walking through the previous command, the first line gets a list of all the disks attached to the system. The second filters them to only ones that are USB drives. Those results are sent to Out-GridView for the user to select the USB drive to format in case more than one USB drive is attached to the system (you can only blame yourself if you select the wrong one).

The fourth clears all data and partitions off of the disk. The fifth creates a new partition using all of the available space on the USB drive and assigns a drive letter to it. The last line formats the USB drive. While many tutorials use NTFS as the type of file system, I found that my Lenovo ThinkPad P50 will not boot from a Windows 10 USB drive formatted with NTFS. It boots fine from one formatted with FAT32. Trying to use FAT32 for Windows Server 2016 generates an error though, so you’ll need to use NTFS for it.

Mount the ISO. The problem I ran into is there’s no easy way to determine what drive letter is assigned to an ISO once it’s mounted. The simplest way I found is to compare the drive letters before and after mounting it. While this sounds simple, another problem I ran into was that Compare-Object doesn’t handle null values.

Change directory into the boot folder on the drive of the mounted ISO. Make the drive bootable and copy the contents of the ISO to the USB drive.

While I’ve tried to do as much of this process as possible in PowerShell, there’s still a need to use a few command line utilities to accomplish this task. Thankfully, it’s something that you shouldn’t have to do very often. For ease of reuse, label your USB drive with a label maker, not a permanent marker.

The original version of this blog article used xcopy.exe to copy the files. That portion of this blog article has been updated to use the PowerShell Copy-Item cmdlet.



  1. Bob

    Please describe what this USB drive can do when booted from it. Is it just for Windows installation? Do we get something like BartPE? A command shell? A full OS? Thanks!

  2. Tony R Auby

    Is the code to this on a github or some place? A link to that would be nice.

  3. Steve

    Thanks Mike for a Great Blog Post. Very Helpful.

  4. Marc

    The error you get with Server 2016 and FAT32 is because the install.wim file is bigger than 4GB. You need to use dism /split-image to copy the install.wim on the USB key.

  5. lanfust

    Trying your script to make an usb bootable with last windows insider 18860 but have this issue
    Container cannot be copied onto existing leaf item

    error is about this line
    Copy-Item -Path “$($ISO):\*” -Destination “$($Results.DriveLetter):” -Recurse -Verbose

    and i don’t understand why

  6. IHate Windows

    Wow! Windows stinks up the joint!
    NO simple ISO utility. NO simple zip/unzip utility.
    Go Linux!

  7. Luke Stanley-Ryan

    For getting the Volume letter you can do:

    $DiskLetter = Mount-DiskImage -ImagePath C:\ISO\SW_DVD5_Win_Pro_Ent_Edu_N_10_1709_64BIT_English_MLF_X21-50143.ISO | Get-Volume | Select-Object -ExpandProperty DriveLetter

  8. Luke Stanley-Ryan

    For the mounted drive letter you can do:

    $DiskImage = Mount-DiskImage -ImagePath C:\ISO\SW_DVD5_Win_Pro_Ent_Edu_N_10_1709_64BIT_English_MLF_X21-50143.ISO | Get-DiskImage | Get-Volume | Select-Object -ExpandProperty DriveLetter

  9. Rocky

    Can yo please tell me why ths is not working … thanks.
    PS G:\boot> Set-Location -Path “$($ISO):\boot”
    >> bootsect.exe /nt60 “$($Results.DriveLetter):”
    >> Copy-Item -Path “$($ISO):\*” -Destination “$($Results.DriveLetter):” -Recurse -Verbose

    bootsect {/help|/nt60|/nt52} {SYS|ALL|:} [/force] [/mbr]

    Boot sector restoration tool

    Bootsect.exe updates the master boot code for hard disk partitions in order to
    switch between BOOTMGR and NTLDR. You can use this tool to restore the boot
    sector on your computer.

    Run “bootsect /help” for detailed usage instructions.
    VERBOSE: Performing the operation “Copy Directory” on target “Item: G:\boot Destination: G:\boot\:”.
    VERBOSE: Performing the operation “Create Directory” on target “Destination: G:\boot\:”.
    Copy-Item : The given path’s format is not supported.
    At line:3 char:1
    + Copy-Item -Path “$($ISO):\*” -Destination “$($Results.DriveLetter):” …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Copy-Item], NotSupportedException
    + FullyQualifiedErrorId : System.NotSupportedException,Microsoft.PowerShell.Commands.CopyItemCommand

  10. Rocky

    Never mind. I figured it out.

  11. Steve Nordquist

    This is hilarious, writing all this to get excess options and not replicate disk ID, but how about something that replaces ># dd if=Some.iso of=sdg bs=4k but in PowerShell? Or even better, how would one make a boot flash full of UEFI update images and OS distros?


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: