A recommendation: learn coding!
Coding is extremely fun and addictive, even when done in its simplest form like creating a batch file or a PowerShell script. I have spent last three days (and nights, thanks to insomnia, thanks a lot @EdTittel!) writing a PowerShell script that takes your Windows 10 install media, downloads and applies all updates to it (updates released since media was created), creates a new updated install.wim and finally writes the updated WIndows install files to a USB flash drive.
At the moment I have some 900+ lines of code in script in five modules, including some 100+ empty and remark lines to clarify and make script more readable.
What I like in PowerShell scripting is that it follows the basic rules of object-oriented programming; you can do it in modules and then based on what you need, just put relevant modules together to create the script you need.
For those of you who want an easy way to create a USB install media, here's one module from that master script, the one that makes a bootable USB install media for UEFI / GPT systems without any third party applications:
Code:
############################################################
# W10USB - A PS Script to create a bootable USB drive for
# installing Windows on UEFI based PCs with GPT partitioning
#
# You are free to use, edit & share this script as you wish,
# as long as TenForums.com is mentioned as source.
#
# Kari The Finn 17-JUL-2017
# - TenForums.com/members/kari.html
# - Twitter.com/KariTheFinn
# - YouTube.com/KariTheFinn
############################################################
cls
$Text = @"
Mount (double click) a Windows 10 ISO image.
Check the drive letter for mounted ISO, type it below and
press Enter.
Please notice: Enter drive letter as a single letter without
colon (for example W or w, not W: or w:).
"@
$ISOFolder = Read-Host -Prompt $Text
cls
Write-Host
Write-Host ' Plug in a USB drive (min. size 6 GB).'
Write-Host
Write-Host ' Notice: Remove all other USB flash drives'
Write-Host ' leaving only the one to be used connected.'
Write-Host
Write-Host ' If more than 1 USB flash drive are connected'
Write-Host ' this process will fail.'
Write-Host
Write-Host ' External USB hard disks may remain connected,'
Write-Host ' just remove all additional USB flash drives.'
Write-Host
pause
cls
Write-Host
Get-Disk
Write-Host
$Text = @"
Above is a list of all your connected disks.
Enter the Disk Number (left column) for USB
drive to be used as bootable Windows install
media.
Be careful!
Selected disk will be wiped clean and formatted.
Selecting wrong disk, you will lose any data on it.
If you are unsure, press CTRL + C to abort this script.
Enter your selection, and press Enter:
"@
$USBNUMBER = Read-Host -Prompt $Text
$Text = @"
Are you sure?
Selected disk will be completely wiped and formatted!
Please type YES (not case sensitive) and press Enter
to confirm, any other key or string + Enter to exit.
"@
$AreYouSure = Read-Host -Prompt $Text
if ($AreYouSure -ne 'YES')
{exit}
else
{cls}
cls
Write-Host
Write-Host ' Wiping USB flash drive clean & formatting it'
Clear-Disk -Number $USBNUMBER -RemoveData
New-Partition –DiskNumber $USBNUMBER -UseMaximumSize -AssignDriveLetter | Out-Null
$USBDrive = Get-WmiObject Win32_Volume -Filter "DriveType='2'"
$USBDrive = $USBDrive.DriveLetter
Format-Volume -FileSystem FAT32 -DriveLetter $USBDrive.Trim(":", " ")
$USBDrive = ($USBDrive + '\')
cls
Write-Host
Write-Host ' Copying installation files to USB...'
$ISOFolder = ($ISOFolder + ':\')
$Files = Get-ChildItem -Path $ISOFolder -Recurse
$FileCount = $Files.count
$i=0
Foreach ($File in $Files) {
$i++
Write-Progress -activity "Copying files to USB. Get a cup of java or shot of single malt, this will take a few minutes..." -status "$File ($i of $FileCount)" -percentcomplete (($i/$FileCount)*100)
if ($File.psiscontainer) {$SourcefileContainer = $File.parent} else {$SourcefileContainer = $File.directory}
$RelativePath = $SourcefileContainer.fullname.SubString($ISOFolder.length)
Copy-Item $File.fullname ($USBDrive + $RelativePath)
}
cls
Write-Host
Write-Host ' Bootable Windows 10 install USB drive for UEFI / GPT systems created.'
Write-Host
Write-Host ' More Windows 10 tips, tricks, videos & tutorials at'
Write-Host ' https://www.tenforums.com'
Write-Host
Short instructions:- Download the zip archive:
W10USB.zip
-
Unblock the archive (
tutorial), extract script to a folder
- Open an
elevated PowerShell
- Enter command
Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force
- Enter command
& 'I:\OneDrive\PS Scripts\W10USB.ps1'
. Change path to actual path where you extracted
W10USB.ps1 script, in my example case the script is stored at
I:\OneDrive\PS Scripts folder:
- Follow on-screen instructions:
Script works both with ESD and WIM based install media, in screenshot I am creating USB install media from dual architecture ESD based W10 ISO made with Media Creation Tool:
Please notice, Windows shows this prompt when script has created new partition on USB drive:
You can just ignore it, close it by clicking Cancel, USB drive will be formatted by the script.
That's it! Script is failproof if you follow the instructions given.
Kari