How to create a bootable USB ISO using PowerShell

Home > Search > How-to

Use this PowerShell script to create a bootable USB flash drive from an ISO file. Modify line 3 to point to your ISO file. I did not write this PowerShell script. I found this PowerShell script at

Wait until The operation completed successfully is displayed before removing the USB flash drive from the PC.

# minimum size of USB stick 5.29GB

# Set here the path of your ISO file
$iso = 'C:\Users\john.doe\Downloads\en_windows_server_2016_x64_dvd_9327751.iso'

# Clean ! will clear any plugged-in USB stick!!
Get-Disk | Where BusType -eq 'USB' | 
Clear-Disk -RemoveData -Confirm:$true -PassThru

# Convert GPT
if ((Get-Disk | Where BusType -eq 'USB').PartitionStyle -eq 'RAW') {
    Get-Disk | Where BusType -eq 'USB' | 
    Initialize-Disk -PartitionStyle GPT
} else {
    Get-Disk | Where BusType -eq 'USB' | 
    Set-Disk -PartitionStyle GPT

# Create partition primary and format to FAT32
$volume = Get-Disk | Where BusType -eq 'USB' | 
New-Partition -UseMaximumSize -AssignDriveLetter | 
Format-Volume -FileSystem FAT32

if (Test-Path -Path "$($volume.DriveLetter):\") {

    # Mount iso
    $miso = Mount-DiskImage -ImagePath $iso -StorageType ISO -PassThru

    # Driver letter
    $dl = ($miso | Get-Volume).DriveLetter

if (Test-Path -Path "$($dl):\sources\install.wim") {

    # Copy ISO content to USB except install.wim
    & (Get-Command "$($env:systemroot)\system32\robocopy.exe") @(

    # Split install.wim
    & (Get-Command "$($env:systemroot)\system32\dism.exe") @(

# Eject USB
(New-Object -comObject Shell.Application).NameSpace(17).

# Dismount ISO
Dismount-DiskImage -ImagePath $iso


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter in the box below so that we can be sure you are a human.