Compare commits

..

11 Commits
v1.19 ... v1.25

Author SHA1 Message Date
Biswapriyo Nath
b1eebac8dc Add Windows 10 Redstone 5 17763.379 builds
* Closes #25
2021-09-25 21:11:17 +01:00
Pete Batard
8508ac6164 Add UEFI Shell 2.0 ISO downloads
* Also retrieve archs from the GitHub releases
* Also add Shell 2.2 21H2 download
2021-08-30 21:41:07 +01:00
Pete Batard
eac06c958f Update README.md 2021-08-24 16:49:42 +02:00
Pete Batard
2ee5f896d3 Add UEFI Shell bootable ISO downloads 2021-08-24 16:43:44 +02:00
Pete Batard
28725b287c Update README.md 2021-08-19 23:00:56 +02:00
Pete Batard
b7331f7873 Fix download of Windows 10 1507
* This versions uses weird SkuIds ('FQC-08932', 'FQC-08929', ...) that aren't integers...
* Closes pbatard/rufus#1769
2021-08-19 22:48:59 +02:00
Pete Batard
6160db3c66 Improve download handling for commandline
* Report the download size and handle errors
* Also improve exit code and verbosity handling
2021-08-15 13:44:38 +02:00
flx5
8b40c85d76 Add Commandline support
* Also fix a regression introduced by previous commit
* Closes #15
* Closes #24
2021-08-07 23:32:09 +02:00
Pete Batard
f70836e6c1 Split stages into separate function calls
* This is based on work done by flx5 in branch https://github.com/flx5/Fido
2021-08-06 22:39:34 +02:00
Pete Batard
af17001505 Add Windows 7 en-US ISO downloads
* Because why not?
2021-06-10 11:42:44 +01:00
Pete Batard
43adf47d5d Sign our script
* Because why not, and some folks might have policies where this could help.
2021-05-26 17:32:36 +01:00
3 changed files with 764 additions and 150 deletions

841
Fido.ps1
View File

@@ -1,6 +1,7 @@
#
# Fido v1.19 - Retail Windows ISO Downloader
# Fido v1.25 - Feature ISO Downloader, for retail Windows images and UEFI Shell
# Copyright © 2019-2021 Pete Batard <pete@akeo.ie>
# Command line support: Copyright © 2021 flx5
# ConvertTo-ImageSource: Copyright © 2016 Chris Carter
#
# This program is free software: you can redistribute it and/or modify
@@ -30,14 +31,32 @@ param(
[string]$Icon,
# (Optional) Name of a pipe the download URL should be sent to.
# If not provided, a browser window is opened instead.
[string]$PipeName
[string]$PipeName,
# (Optional) Specify Windows version (e.g. "Windows 10") [Toggles commandline mode]
[string]$Win,
# (Optional) Specify Windows release (e.g. "21H1") [Toggles commandline mode]
[string]$Rel,
# (Optional) Specify Windows edition (e.g. "Pro") [Toggles commandline mode]
[string]$Ed,
# (Optional) Specify Windows language [Toggles commandline mode]
[string]$Lang,
# (Optional) Specify Windows architecture [Toggles commandline mode]
[string]$Arch,
# (Optional) Only display the download URL [Toggles commandline mode]
[switch]$GetUrl = $False,
# (Optional) Increase verbosity
[switch]$Verbose = $False
)
#endregion
try {
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
} catch {}
Write-Host Please Wait...
$Cmd = $False
if ($Win -or $Rel -or $Ed -or $Lang -or $Arch -or $GetUrl) {
$Cmd = $True
}
#region Assembly Types
$code = @"
@@ -59,14 +78,17 @@ $code = @"
}
"@
if ($host.version -ge "7.0") {
Add-Type -WarningAction Ignore -IgnoreWarnings -MemberDefinition $code -Namespace Gui -UsingNamespace System.Runtime, System.IO, System.Text, System.Drawing, System.Globalization -ReferencedAssemblies System.Drawing.Common -Name Utils -ErrorAction Stop
} else {
Add-Type -MemberDefinition $code -Namespace Gui -UsingNamespace System.IO, System.Text, System.Drawing, System.Globalization -ReferencedAssemblies System.Drawing -Name Utils -ErrorAction Stop
if (!$Cmd) {
Write-Host Please Wait...
if ($host.version -ge "7.0") {
Add-Type -WarningAction Ignore -IgnoreWarnings -MemberDefinition $code -Namespace Gui -UsingNamespace System.Runtime, System.IO, System.Text, System.Drawing, System.Globalization -ReferencedAssemblies System.Drawing.Common -Name Utils -ErrorAction Stop
} else {
Add-Type -MemberDefinition $code -Namespace Gui -UsingNamespace System.IO, System.Text, System.Drawing, System.Globalization -ReferencedAssemblies System.Drawing -Name Utils -ErrorAction Stop
}
Add-Type -AssemblyName PresentationFramework
# Hide the powershell window: https://stackoverflow.com/a/27992426/1069307
[Gui.Utils]::ShowWindow(([System.Diagnostics.Process]::GetCurrentProcess() | Get-Process).MainWindowHandle, 0) | Out-Null
}
Add-Type -AssemblyName PresentationFramework
# Hide the powershell window: https://stackoverflow.com/a/27992426/1069307
[Gui.Utils]::ShowWindow(([System.Diagnostics.Process]::GetCurrentProcess() | Get-Process).MainWindowHandle, 0) | Out-Null
#endregion
#region Data
@@ -117,6 +139,12 @@ $WindowsVersions = @(
@("Windows 10 Education", 1216),
@("Windows 10 Home China ", ($zh + 1215))
),
@(
"1809 R3 (Build 17763.379 - 2019.03)",
@("Windows 10 Home/Pro", 1203),
@("Windows 10 Education", 1202),
@("Windows 10 Home China ", ($zh + 1204))
),
@(
"1809 R2 (Build 17763.107 - 2018.10)",
@("Windows 10 Home/Pro", 1060),
@@ -209,14 +237,84 @@ $WindowsVersions = @(
@("Windows 8.1", "windows8ISO"),
@(
"Update 3 (build 9600)",
@("Windows 8.1", 52),
@("Windows 8.1 Standard", 52),
@("Windows 8.1 N", 55)
@("Windows 8.1 Single Language", 48),
@("Windows 8.1 K", ($ko + 61)),
@("Windows 8.1 KN", ($ko + 62))
)
),
@(
@("Windows 7", "WIN7"),
@(
"with SP1 (build 7601)",
@("Windows 7 Ultimate", 0),
@("Windows 7 Professional", 1),
@("Windows 7 Home Premium", 2)
)
),
@(
@("UEFI Shell 2.2", "UEFI_SHELL 2.2"),
@(
"21H2 (edk2-stable202108)",
@("Release", 0),
@("Debug", 1)
),
@(
"21H1 (edk2-stable202105)",
@("Release", 0),
@("Debug", 1)
),
@(
"20H2 (edk2-stable202011)",
@("Release", 0),
@("Debug", 1)
)
),
@(
@("UEFI Shell 2.0", "UEFI_SHELL 2.0"),
@(
"4.632 [20100426]",
@("Release", 0)
)
)
)
$Windows7Versions = @(
# 0: Windows 7 Ultimate
@(
# Need a dummy to prevent PS from coalescing single array entries
@(""),
@("English (US)", "en-us",
@(
@("x64", "https://download.microsoft.com/download/5/1/9/5195A765-3A41-4A72-87D8-200D897CBE21/7601.24214.180801-1700.win7sp1_ldr_escrow_CLIENT_ULTIMATE_x64FRE_en-us.iso"),
@("x86", "https://download.microsoft.com/download/1/E/6/1E6B4803-DD2A-49DF-8468-69C0E6E36218/7601.24214.180801-1700.win7sp1_ldr_escrow_CLIENT_ULTIMATE_x86FRE_en-us.iso")
)
)
),
# 1: Windows 7 Profesional
@(
@(""),
@("English (US)", "en-us",
@(
@("x64", "https://download.microsoft.com/download/0/6/3/06365375-C346-4D65-87C7-EE41F55F736B/7601.24214.180801-1700.win7sp1_ldr_escrow_CLIENT_PROFESSIONAL_x64FRE_en-us.iso"),
@("x86", "https://download.microsoft.com/download/C/0/6/C067D0CD-3785-4727-898E-60DC3120BB14/7601.24214.180801-1700.win7sp1_ldr_escrow_CLIENT_PROFESSIONAL_x86FRE_en-us.iso")
)
)
),
# 2: Windows 7 Home Premium
@(
@(""),
@("English (US)", "en-us",
@(
@("x64", "https://download.microsoft.com/download/E/A/8/EA804D86-C3DF-4719-9966-6A66C9306598/7601.24214.180801-1700.win7sp1_ldr_escrow_CLIENT_HOMEPREMIUM_x64FRE_en-us.iso"),
@("x86", "https://download.microsoft.com/download/E/D/A/EDA6B508-7663-4E30-86F9-949932F443D0/7601.24214.180801-1700.win7sp1_ldr_escrow_CLIENT_HOMEPREMIUM_x86FRE_en-us.iso")
)
)
)
)
#endregion
#region Functions
@@ -318,7 +416,7 @@ function Add-Entry([int]$pos, [string]$Name, [array]$Items, [string]$DisplayName
function Refresh-Control([object]$Control)
{
$Control.Dispatcher.Invoke("Render", [Windows.Input.InputEventHandler] { $Continue.UpdateLayout() }, $null, $null)
$Control.Dispatcher.Invoke("Render", [Windows.Input.InputEventHandler] { $Continue.UpdateLayout() }, $null, $null) | Out-Null
}
function Send-Message([string]$PipeName, [string]$Message)
@@ -407,11 +505,15 @@ function GetElementById([object]$Request, [string]$Id)
function Error([string]$ErrorMessage)
{
Write-Host Error: $ErrorMessage
$XMLForm.Title = $(Get-Translation("Error")) + ": " + $ErrorMessage
Refresh-Control($XMLForm)
$XMLGrid.Children[2 * $script:Stage + 1].IsEnabled = $True
$UserInput = [System.Windows.MessageBox]::Show($XMLForm.Title, $(Get-Translation("Error")), "OK", "Error")
$script:ExitCode = $script:Stage--
if (!$Cmd) {
$XMLForm.Title = $(Get-Translation("Error")) + ": " + $ErrorMessage
Refresh-Control($XMLForm)
$XMLGrid.Children[2 * $script:Stage + 1].IsEnabled = $True
$UserInput = [System.Windows.MessageBox]::Show($XMLForm.Title, $(Get-Translation("Error")), "OK", "Error")
$script:ExitCode = $script:Stage--
} else {
$script:ExitCode = 2
}
}
function Get-RandomDate()
@@ -442,20 +544,34 @@ function Get-RandomDate()
#region Globals
$ErrorActionPreference = "Stop"
$dh = 58;
$dh = 58
$Stage = 0
$SelectedIndex = 0
$ltrm = ""
if ($Cmd) {
$ltrm = ""
}
$MaxStage = 4
$SessionId = [guid]::NewGuid()
$ExitCode = 100
$Locale = "en-US"
$RequestData = @{}
# This GUID applies to all visitors, regardless of their locale
$RequestData["GetLangs"] = @("a8f8f489-4c7f-463a-9ca6-5cff94d8d041", "getskuinformationbyproductedition" )
$RequestData["GetLinks"] = @("cfa9e580-a81e-4a4b-a846-7b21bf4e2e5b", "GetProductDownloadLinksBySku" )
# This GUID applies to visitors of the en-US download page. Other locales may get a different GUID.
$RequestData["GetLinks"] = @("a224afab-2097-4dfa-a2ba-463eb191a285", "GetProductDownloadLinksBySku" )
# Create a semi-random Linux User-Agent string
$FirefoxVersion = Get-Random -Minimum 50 -Maximum 90
$FirefoxDate = Get-RandomDate
$UserAgent = "Mozilla/5.0 (X11; Linux i586; rv:$FirefoxVersion.0) Gecko/$FirefoxDate Firefox/$FirefoxVersion.0"
$Verbosity = 2
if ($Cmd) {
if ($GetUrl) {
$Verbosity = 0
} elseif (!$Verbose) {
$Verbosity = 1
}
}
#endregion
# Localization
@@ -484,6 +600,394 @@ if ($PSVersionTable.PSVersion.Major -lt 3) {
exit 102
}
# Convert a size in bytes to a human readable string
function Size-To-Human-Readable([uint64]$size)
{
$suffix = "bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"
$i = 0
while ($size -gt 1kb) {
$size = $size / 1kb
$i++
}
"{0:N1} {1}" -f $size, $suffix[$i]
}
# Check if the locale we want is available - Fall back to en-US otherwise
function Check-Locale {
try {
$url = "https://www.microsoft.com/" + $QueryLocale + "/software-download/"
if ($Verbosity -ge 2) {
Write-Host Querying $url
}
Invoke-WebRequest -UseBasicParsing -MaximumRedirection 0 -UserAgent $UserAgent $url | Out-Null
} catch {
$script:QueryLocale = "en-US"
}
}
# Return an array of releases (e.g. 20H2, 21H1, ...) for the selected Windows version
function Get-Windows-Releases([int]$SelectedVersion)
{
$i = 0
$releases = @()
foreach ($version in $WindowsVersions[$SelectedVersion]) {
if (($i -ne 0) -and ($version -is [array])) {
$releases += @(New-Object PsObject -Property @{ Release = $ltrm + $version[0].Replace(")", ")" + $ltrm); Index = $i })
}
$i++
}
return $releases
}
# Return an array of editions (e.g. Home, Pro, etc) for the selected Windows release
function Get-Windows-Editions([int]$SelectedVersion, [int]$SelectedRelease)
{
$editions = @()
foreach ($release in $WindowsVersions[$SelectedVersion][$SelectedRelease])
{
if ($release -is [array]) {
if (($release[1] -lt 0x10000) -or ($Locale.StartsWith("ko") -and ($release[1] -band $ko)) -or ($Locale.StartsWith("zh") -and ($release[1] -band $zh))) {
$editions += @(New-Object PsObject -Property @{ Edition = $release[0]; Id = $($release[1] -band 0xFFFF) })
}
}
}
return $editions
}
# Return an array of languages for the selected edition
function Get-Windows-Languages([int]$SelectedVersion, [int]$SelectedEdition)
{
$languages = @()
$i = 0;
if ($WindowsVersions[$SelectedVersion][0][1] -eq "WIN7") {
foreach ($entry in $Windows7Versions[$SelectedEdition]) {
if ($entry[0] -ne "") {
$languages += @(New-Object PsObject -Property @{ DisplayLanguage = $entry[0]; Language = $entry[1]; Id = $i })
}
$i++
}
} elseif ($WindowsVersions[$SelectedVersion][0][1].StartsWith("UEFI_SHELL")) {
$languages += @(New-Object PsObject -Property @{ DisplayLanguage = "English (US)"; Language = "en-us"; Id = 0 })
} else {
$url = "https://www.microsoft.com/" + $QueryLocale + "/api/controls/contentinclude/html"
$url += "?pageId=" + $RequestData["GetLangs"][0]
$url += "&host=www.microsoft.com"
$url += "&segments=software-download," + $WindowsVersions[$SelectedVersion][0][1]
$url += "&query=&action=" + $RequestData["GetLangs"][1]
$url += "&sessionId=" + $SessionId
$url += "&productEditionId=" + [Math]::Abs($SelectedEdition)
$url += "&sdVersion=2"
if ($Verbosity -ge 2) {
Write-Host Querying $url
}
$script:SelectedIndex = 0
try {
$r = Invoke-WebRequest -UseBasicParsing -UserAgent $UserAgent -SessionVariable "Session" $url
if ($r -match "errorModalMessage") {
Throw-Error -Req $r -Alt "Could not retrieve languages from server"
}
$pattern = '(?s)<select id="product-languages">(.*)?</select>'
$html = [regex]::Match($r, $pattern).Groups[1].Value
# Go through an XML conversion to keep all PowerShells happy...
$html = $html.Replace("selected value", "value")
$html = "<options>" + $html + "</options>"
$xml = [xml]$html
foreach ($var in $xml.options.option) {
$json = $var.value | ConvertFrom-Json;
if ($json) {
$languages += @(New-Object PsObject -Property @{ DisplayLanguage = $var.InnerText; Language = $json.language; Id = $json.id })
if (Select-Language($json.language)) {
$script:SelectedIndex = $i
}
$i++
}
}
if ($languages.Length -eq 0) {
Throw-Error -Req $r -Alt "Could not parse languages"
}
} catch {
Error($_.Exception.Message)
return @()
}
}
return $languages
}
# Return an array of download links for each supported arch
function Get-Windows-Download-Links([int]$SelectedVersion, [int]$SelectedRelease, [int]$SelectedEdition, [string]$SkuId, [string]$LanguageName)
{
$links = @()
if ($WindowsVersions[$SelectedVersion][0][1] -eq "WIN7") {
foreach ($Version in $Windows7Versions[$SelectedEdition][$SkuId][2]) {
$links += @(New-Object PsObject -Property @{ Type = $Version[0]; Link = $Version[1] })
}
} elseif ($WindowsVersions[$SelectedVersion][0][1].StartsWith("UEFI_SHELL")) {
$tag = $WindowsVersions[$SelectedVersion][$SelectedRelease][0].Split(' ')[0]
$shell_version = $WindowsVersions[$SelectedVersion][0][1].Split(' ')[1]
$url = "https://github.com/pbatard/UEFI-Shell/releases/download/" + $tag
$link = $url + "/UEFI-Shell-" + $shell_version + "-" + $tag
if ($SelectedEdition -eq 0) {
$link += "-RELEASE.iso"
} else {
$link += "-DEBUG.iso"
}
try {
# Read the supported archs from the release URL
$url += "/Version.xml"
$xml = New-Object System.Xml.XmlDocument
if ($Verbosity -ge 2) {
Write-Host Querying $url
}
$xml.Load($url)
$sep = ""
$archs = ""
foreach($arch in $xml.release.supported_archs.arch) {
$archs += $sep + $arch
$sep = ", "
}
$links += @(New-Object PsObject -Property @{ Type = $archs; Link = $link })
} catch {
Error($_.Exception.Message)
return @()
}
} else {
$url = "https://www.microsoft.com/" + $QueryLocale + "/api/controls/contentinclude/html"
$url += "?pageId=" + $RequestData["GetLinks"][0]
$url += "&host=www.microsoft.com"
$url += "&segments=software-download," + $WindowsVersions[$SelectedVersion][0][1]
$url += "&query=&action=" + $RequestData["GetLinks"][1]
$url += "&sessionId=" + $SessionId
$url += "&skuId=" + $SkuId
$url += "&language=" + $LanguageName
$url += "&sdVersion=2"
if ($Verbosity -ge 2) {
Write-Host Querying $url
}
$i = 0
$script:SelectedIndex = 0
try {
$Is64 = [Environment]::Is64BitOperatingSystem
$r = Invoke-WebRequest -Method Post -UseBasicParsing -UserAgent $UserAgent -WebSession $Session $url
if ($r -match "errorModalMessage") {
Throw-Error -Req $r -Alt "Could not retrieve architectures from server"
}
$pattern = '(?s)(<input.*?></input>)'
ForEach-Object { [regex]::Matches($r, $pattern) } | ForEach-Object { $html += $_.Groups[1].value }
# Need to fix the HTML and JSON data so that it is well-formed
$html = $html.Replace("class=product-download-hidden", "")
$html = $html.Replace("type=hidden", "")
$html = $html.Replace("&nbsp;", " ")
$html = $html.Replace("IsoX86", "&quot;x86&quot;")
$html = $html.Replace("IsoX64", "&quot;x64&quot;")
$html = "<inputs>" + $html + "</inputs>"
$xml = [xml]$html
foreach ($var in $xml.inputs.input) {
$json = $var.value | ConvertFrom-Json;
if ($json) {
if (($Is64 -and $json.DownloadType -eq "x64") -or (-not $Is64 -and $json.DownloadType -eq "x86")) {
$script:SelectedIndex = $i
}
$links += @(New-Object PsObject -Property @{ Type = $json.DownloadType; Link = $json.Uri })
$i++
}
}
if ($links.Length -eq 0) {
Throw-Error -Req $r -Alt "Could not retrieve ISO download links"
}
} catch {
Error($_.Exception.Message)
return @()
}
}
return $links
}
# Process the download URL by either sending it through the pipe or by opening the browser
function Process-Download-Link([string]$Url)
{
try {
if ($PipeName -and -not $Check.IsChecked) {
Send-Message -PipeName $PipeName -Message $Url
} else {
if ($Cmd) {
$pattern = '.*\/(.*\.iso).*'
$File = [regex]::Match($Url, $pattern).Groups[1].Value
# PowerShell implicit conversions are iffy, so we need to force them...
$str_size = (Invoke-WebRequest -UseBasicParsing -Uri $Url -Method Head).Headers.'Content-Length'
$tmp_size = [uint64]::Parse($str_size)
$Size = Size-To-Human-Readable $tmp_size
Write-Host "Downloading '$File' ($Size)..."
Invoke-WebRequest -UseBasicParsing -Uri $Url -OutFile $File
} else {
Write-Host Download Link: $Url
Start-Process -FilePath $Url
}
}
} catch {
Error($_.Exception.Message)
return 404
}
return 0
}
if ($Cmd) {
$winVersionId = $null
$winReleaseId = $null
$winEditionId = $null
$winLanguageId = $null
$winLanguageName = $null
$winLink = $null
$i = 0
$Selected = ""
if ($Win -eq "List") {
Write-Host "Please select a Windows Version (-Win):"
}
foreach($version in $WindowsVersions) {
if ($Win -eq "List") {
Write-Host " -" $version[0][0]
} elseif ($version[0][0] -match $Win) {
$Selected += $version[0][0]
$winVersionId = $i
break;
}
$i++
}
if ($winVersionId -eq $null) {
if ($Win -ne "List") {
Write-Host "Invalid Windows version provided."
Write-Host "Use '-Win List' for a list of available Windows versions."
}
exit 1
}
# Windows Version selection
$releases = Get-Windows-Releases $winVersionId
if ($Rel -eq "List") {
Write-Host "Please select a Windows Release (-Rel) for ${Selected} (or use 'Latest' for most recent):"
}
foreach ($release in $releases) {
if ($Rel -eq "List") {
Write-Host " -" $release.Release
} elseif (!$Rel -or $release.Release.StartsWith($Rel) -or $Rel -eq "Latest") {
if (!$Rel -and $Verbosity -ge 1) {
Write-Host "No release specified (-Rel). Defaulting to '$($release.Release)'."
}
$Selected += " " + $release.Release
$winReleaseId = $release.Index
break;
}
}
if ($winReleaseId -eq $null) {
if ($Rel -ne "List") {
Write-Host "Invalid Windows release provided."
Write-Host "Use '-Rel List' for a list of available $Selected releases or '-Rel Latest' for latest."
}
exit 1
}
# Windows Release selection => Populate Product Edition
$editions = Get-Windows-Editions $winVersionId $winReleaseId
if ($Ed -eq "List") {
Write-Host "Please select a Windows Edition (-Ed) for ${Selected}:"
}
foreach($edition in $editions) {
if ($Ed -eq "List") {
Write-Host " -" $edition.Edition
} elseif (!$Ed -or $edition.Edition -match $Ed) {
if (!$Ed -and $Verbosity -ge 1) {
Write-Host "No edition specified (-Ed). Defaulting to '$($edition.Edition)'."
}
$Selected += "," + $edition.Edition -replace "Windows [0-9\.]*", ""
$winEditionId = $edition.Id
break;
}
}
if ($winEditionId -eq $null) {
if ($Ed -ne "List") {
Write-Host "Invalid Windows edition provided."
Write-Host "Use '-Ed List' for a list of available editions or remove the -Ed parameter to use default."
}
exit 1
}
# Product Edition selection => Request and populate Languages
$languages = Get-Windows-Languages $winVersionId $winEditionId
if (!$languages) {
exit 3
}
if ($Lang -eq "List") {
Write-Host "Please select a Language (-Lang) for ${Selected}:"
}
$i = 0
foreach ($language in $languages) {
if ($Lang -eq "List") {
Write-Host " -" $language.Language
} elseif ((!$Lang -and $script:SelectedIndex -eq $i) -or ($Lang -and $language.Language -match $Lang)) {
if (!$Lang -and $Verbosity -ge 1) {
Write-Host "No language specified (-Lang). Defaulting to '$($language.Language)'."
}
$Selected += ", " + $language.Language
$winLanguageId = $language.Id
$winLanguageName = $language.Language
break;
}
$i++
}
if ($winLanguageId -eq $null -or $winLanguageName -eq $null) {
if ($Lang -ne "List") {
Write-Host "Invalid Windows language provided."
Write-Host "Use '-Lang List' for a list of available languages or remove the option to use system default."
}
exit 1
}
# Language selection => Request and populate Arch download links
$links = Get-Windows-Download-Links $winVersionId $winReleaseId $winEditionId $winLanguageId $winLanguageName
if (!$links) {
exit 3
}
if ($Arch -eq "List") {
Write-Host "Please select an Architecture (-Arch) for ${Selected}:"
}
$i = 0
foreach ($link in $links) {
if ($Arch -eq "List") {
Write-Host " -" $link.Type
} elseif ((!$Arch -and $script:SelectedIndex -eq $i) -or ($Arch -and $link.Type -match $Arch)) {
if (!$Arch -and $Verbosity -ge 1) {
Write-Host "No architecture specified (-Arch). Defaulting to '$($link.Type)'."
}
$Selected += ", [" + $link.Type + "]"
$winLink = $link
break;
}
$i++
}
if ($winLink -eq $null) {
if ($Arch -ne "List") {
Write-Host "Invalid Windows architecture provided."
Write-Host "Use '-Arch List' for a list of available architectures or remove the option to use system default."
}
exit 1
}
# Arch selection => Return selected download link
if ($GetUrl) {
Return $winLink.Link
$ExitCode = 0
} else {
Write-Host "Selected: $Selected"
$ExitCode = Process-Download-Link $winLink.Link
}
# Clean up & exit
exit $ExitCode
}
# Form creation
$XMLForm = [Windows.Markup.XamlReader]::Load((New-Object System.Xml.XmlNodeReader $XAML))
$XAML.SelectNodes("//*[@Name]") | ForEach-Object { Set-Variable -Name ($_.Name) -Value $XMLForm.FindName($_.Name) -Scope Script }
@@ -493,7 +997,7 @@ if ($Icon) {
} else {
$XMLForm.Icon = [Gui.Utils]::ExtractIcon("shell32.dll", -41, $true) | ConvertTo-ImageSource
}
if ($Locale.StartsWith("ar") -or $Locale.StartsWith("fa") -or $Locale.StartsWith("he")) {
if ($Locale.StartsWith("ar") -or $Locale.StartsWith("fa") -or $Locale.StartsWith("he")) {
$XMLForm.FlowDirection = "RightToLeft"
}
$WindowsVersionTitle.Text = Get-Translation("Version")
@@ -502,12 +1006,12 @@ $Back.Content = Get-Translation("Close")
# Populate the Windows versions
$i = 0
$array = @()
foreach($Version in $WindowsVersions) {
$array += @(New-Object PsObject -Property @{ Version = $Version[0][0]; PageType = $Version[0][1]; Index = $i })
$versions = @()
foreach($version in $WindowsVersions) {
$versions += @(New-Object PsObject -Property @{ Version = $version[0][0]; PageType = $version[0][1]; Index = $i })
$i++
}
$WindowsVersion.ItemsSource = $array
$WindowsVersion.ItemsSource = $versions
$WindowsVersion.DisplayMemberPath = "Version"
# Button Action
@@ -524,137 +1028,40 @@ $Continue.add_click({
1 { # Windows Version selection
$XMLForm.Title = Get-Translation($English[12])
Refresh-Control($XMLForm)
# Check if the locale we want is available - Fall back to en-US otherwise
try {
$url = "https://www.microsoft.com/" + $QueryLocale + "/software-download/"
Write-Host Querying $url
Invoke-WebRequest -UseBasicParsing -MaximumRedirection 0 -UserAgent $UserAgent $url | Out-Null
} catch {
$script:QueryLocale = "en-US"
if ($WindowsVersion.SelectedValue.Version.StartsWith("Windows") -and $WindowsVersion.SelectedValue.Version -ne "Windows 7") {
Check-Locale
}
$i = 0
$array = @()
foreach ($Version in $WindowsVersions[$WindowsVersion.SelectedValue.Index]) {
if (($i -ne 0) -and ($Version -is [array])) {
$array += @(New-Object PsObject -Property @{ Release = $ltrm + $Version[0].Replace(")", ")" + $ltrm); Index = $i })
}
$i++
}
$script:WindowsRelease = Add-Entry $Stage "Release" $array
$releases = Get-Windows-Releases $WindowsVersion.SelectedValue.Index
$script:WindowsRelease = Add-Entry $Stage "Release" $releases
$Back.Content = Get-Translation($English[8])
$XMLForm.Title = $AppTitle
}
2 { # Windows Release selection => Populate Product Edition
$array = @()
foreach ($Release in $WindowsVersions[$WindowsVersion.SelectedValue.Index][$WindowsRelease.SelectedValue.Index])
{
if ($Release -is [array]) {
if (($Release[1] -lt 0x10000) -or ($Locale.StartsWith("ko") -and ($Release[1] -band $ko)) -or ($Locale.StartsWith("zh") -and ($Release[1] -band $zh))) {
$array += @(New-Object PsObject -Property @{ Edition = $Release[0]; Id = $($Release[1] -band 0xFFFF) })
}
}
}
$script:ProductEdition = Add-Entry $Stage "Edition" $array
$editions = Get-Windows-Editions $WindowsVersion.SelectedValue.Index $WindowsRelease.SelectedValue.Index
$script:ProductEdition = Add-Entry $Stage "Edition" $editions
}
3 { # Product Edition selection => Request and populate Languages
3 { # Product Edition selection => Request and populate languages
$XMLForm.Title = Get-Translation($English[12])
Refresh-Control($XMLForm)
$url = "https://www.microsoft.com/" + $QueryLocale + "/api/controls/contentinclude/html"
$url += "?pageId=" + $RequestData["GetLangs"][0]
$url += "&host=www.microsoft.com"
$url += "&segments=software-download," + $WindowsVersion.SelectedValue.PageType
$url += "&query=&action=" + $RequestData["GetLangs"][1]
$url += "&sessionId=" + $SessionId
$url += "&productEditionId=" + [Math]::Abs($ProductEdition.SelectedValue.Id)
$url += "&sdVersion=2"
Write-Host Querying $url
$array = @()
$i = 0
$SelectedIndex = 0
try {
$r = Invoke-WebRequest -UseBasicParsing -UserAgent $UserAgent -SessionVariable "Session" $url
$pattern = '(?s)<select id="product-languages">(.*)?</select>'
$html = [regex]::Match($r, $pattern).Groups[1].Value
# Go through an XML conversion to keep all PowerShells happy...
$html = $html.Replace("selected value", "value")
$html = "<options>" + $html + "</options>"
$xml = [xml]$html
foreach ($var in $xml.options.option) {
$json = $var.value | ConvertFrom-Json;
if ($json) {
$array += @(New-Object PsObject -Property @{ DisplayLanguage = $var.InnerText; Language = $json.language; Id = $json.id })
if (Select-Language($json.language)) {
$SelectedIndex = $i
}
$i++
}
}
if ($array.Length -eq 0) {
Throw-Error -Req $r -Alt "Could not parse languages"
}
} catch {
Error($_.Exception.Message)
$languages = Get-Windows-Languages $WindowsVersion.SelectedValue.Index $ProductEdition.SelectedValue.Id
if ($languages.Length -eq 0) {
break
}
$script:Language = Add-Entry $Stage "Language" $array "DisplayLanguage"
$Language.SelectedIndex = $SelectedIndex
$script:Language = Add-Entry $Stage "Language" $languages "DisplayLanguage"
$Language.SelectedIndex = $script:SelectedIndex
$XMLForm.Title = $AppTitle
}
4 { # Language selection => Request and populate Arch download links
$XMLForm.Title = Get-Translation($English[12])
Refresh-Control($XMLForm)
$url = "https://www.microsoft.com/" + $QueryLocale + "/api/controls/contentinclude/html"
$url += "?pageId=" + $RequestData["GetLinks"][0]
$url += "&host=www.microsoft.com"
$url += "&segments=software-download," + $WindowsVersion.SelectedValue.PageType
$url += "&query=&action=" + $RequestData["GetLinks"][1]
$url += "&sessionId=" + $SessionId
$url += "&skuId=" + $Language.SelectedValue.Id
$url += "&language=" + $Language.SelectedValue.Language
$url += "&sdVersion=2"
Write-Host Querying $url
$i = 0
$SelectedIndex = 0
$array = @()
try {
$Is64 = [Environment]::Is64BitOperatingSystem
$r = Invoke-WebRequest -UseBasicParsing -UserAgent $UserAgent -WebSession $Session $url
$pattern = '(?s)(<input.*?/>)'
ForEach-Object { [regex]::Matches($r, $pattern) } | ForEach-Object { $html += $_.Groups[1].value }
# Need to fix the HTML and JSON data so that it is well-formed
$html = $html.Replace("class=product-download-hidden", "")
$html = $html.Replace("type=hidden", "")
$html = $html.Replace("&nbsp;", " ")
$html = $html.Replace("IsoX86", "&quot;x86&quot;")
$html = $html.Replace("IsoX64", "&quot;x64&quot;")
$html = "<inputs>" + $html + "</inputs>"
$xml = [xml]$html
foreach ($var in $xml.inputs.input) {
$json = $var.value | ConvertFrom-Json;
if ($json) {
if (($Is64 -and $json.DownloadType -eq "x64") -or (-not $Is64 -and $json.DownloadType -eq "x86")) {
$SelectedIndex = $i
}
$array += @(New-Object PsObject -Property @{ Type = $json.DownloadType; Link = $json.Uri })
$i++
}
}
if ($array.Length -eq 0) {
Throw-Error -Req $r -Alt "Could not retrieve ISO download links"
}
} catch {
Error($_.Exception.Message)
$links = Get-Windows-Download-Links $WindowsVersion.SelectedValue.Index $WindowsRelease.SelectedValue.Index $ProductEdition.SelectedValue.Id $Language.SelectedValue.Id $Language.SelectedValue.Language
if ($links.Length -eq 0) {
break
}
$script:Arch = Add-Entry $Stage "Architecture" $array "Type"
$script:Architecture = Add-Entry $Stage "Architecture" $links "Type"
if ($PipeName) {
$XMLForm.Height += $dh / 2;
$Margin = $Continue.Margin
@@ -670,19 +1077,13 @@ $Continue.add_click({
$Check.Content = Get-Translation($English[13])
$Check.Visibility = "Visible"
}
$Arch.SelectedIndex = $SelectedIndex
$Architecture.SelectedIndex = $script:SelectedIndex
$Continue.Content = Get-Translation("Download")
$XMLForm.Title = $AppTitle
}
5 { # Arch selection => Return selected download link
if ($PipeName -and -not $Check.IsChecked) {
Send-Message -PipeName $PipeName -Message $Arch.SelectedValue.Link
} else {
Write-Host Download Link: $Arch.SelectedValue.Link
Start-Process -FilePath $Arch.SelectedValue.Link
}
$script:ExitCode = 0
$script:ExitCode = Process-Download-Link $Architecture.SelectedValue.Link
$XMLForm.Close()
}
}
@@ -728,3 +1129,157 @@ $XMLForm.ShowDialog() | Out-Null
# Clean up & exit
exit $ExitCode
# SIG # Begin signature block
# MIIcQwYJKoZIhvcNAQcCoIIcNDCCHDACAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCB+fBaZ2mVh5y0g
# 32xIb+Bor/eyDypG1v6SnGzMw3Q8uaCCCy4wggVGMIIELqADAgECAhAkaSZj72wM
# Cjsjz6MQw2SbMA0GCSqGSIb3DQEBCwUAMH0xCzAJBgNVBAYTAkdCMRswGQYDVQQI
# ExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAOBgNVBAcTB1NhbGZvcmQxGjAYBgNVBAoT
# EUNPTU9ETyBDQSBMaW1pdGVkMSMwIQYDVQQDExpDT01PRE8gUlNBIENvZGUgU2ln
# bmluZyBDQTAeFw0xODAzMTYwMDAwMDBaFw0yMjAzMTYyMzU5NTlaMIGTMQswCQYD
# VQQGEwJJRTERMA8GA1UEEQwIRjkyIEQ2NjcxFDASBgNVBAgMC0NvLiBEb25lZ2Fs
# MRAwDgYDVQQHDAdNaWxmb3JkMRUwEwYDVQQJDAwyN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LPuMzW4IPxbeG
# Ak5xn+lmRT92MYICWjCCAlYCAQEwgYswdzELMAkGA1UEBhMCVVMxHTAbBgNVBAoT
# FFN5bWFudGVjIENvcnBvcmF0aW9uMR8wHQYDVQQLExZTeW1hbnRlYyBUcnVzdCBO
# ZXR3b3JrMSgwJgYDVQQDEx9TeW1hbnRlYyBTSEEyNTYgVGltZVN0YW1waW5nIENB
# AhB71OWvuswHP6EBIwQiQU0SMAsGCWCGSAFlAwQCAaCBpDAaBgkqhkiG9w0BCQMx
# DQYLKoZIhvcNAQkQAQQwHAYJKoZIhvcNAQkFMQ8XDTIxMDkyNTIwMTAzNFowLwYJ
# KoZIhvcNAQkEMSIEIC7+vI6weyx8DY4Bu4hxKgfNagWArytWKYT8536uCXNoMDcG
# CyqGSIb3DQEJEAIvMSgwJjAkMCIEIMR0znYAfQI5Tg2l5N58FMaA+eKCATz+9lPv
# Xbcf32H4MAsGCSqGSIb3DQEBAQSCAQB26Kf/vROm6/cOAM0KxWb+EP2OmU11ccJJ
# bBJbIvEKpiPTs5VMx1yTY7E8es/QDY0PvQCsfSGsoGHGPhjV9EFmDmUg/wKWAPoS
# oQ3hsp8snUBLfEVQtFUSaLSxTlrrYonMCxJazsRSy7a+aZog1tEWv7MIIGf57aNi
# NsKm2TsV+b65T5Z0CcryZuRwA2kx/Mr1BtNf67IXR+09TZlBVtjZXDGfdNlHI1yl
# DlCuh8frb5izoiWYD21hs8xx8ep2Ml4tgw7VqwzWz9tfXl3K61Y9ltnEUuY0nElr
# 71llMJz6eXl1tJVcX3GCIaFb/QbWNFr1gSLC+OjvcJHh1BvXrL+W
# SIG # End signature block

View File

@@ -1,5 +1,5 @@
Fido: Full ISO Download Script (for Windows retail ISOs)
========================================================
Fido: A PowerShell download script for Windows ISOs and UEFI Shell
==================================================================
[![Licence](https://img.shields.io/badge/license-GPLv3-blue.svg?style=flat-square)](https://www.gnu.org/licenses/gpl-3.0.en.html)
[![Github stats](https://img.shields.io/github/downloads/pbatard/Fido/total.svg?style=flat-square)](https://github.com/pbatard/Fido/releases)
@@ -9,7 +9,7 @@ Description
Fido is a PowerShell script that is primarily designed to be used in [Rufus](https://github.com/pbatard/rufus), but that
can also be used in standalone fashion, and whose purpose is to automate access to the official Microsoft Windows retail
ISO download links.
ISO download links as well as provide convenient access to bootable UEFI Shell images.
This script exists because, while Microsoft does make retail ISO download links freely and publicly available (at least
for Windows 8 and Windows 10), it only does so after actively forcing users to jump through a lot of unwarranted hoops,
@@ -50,10 +50,9 @@ redirect you __away__ from the pages that allow you to download retail ISOs):
* https://www.microsoft.com/software-download/Windows8ISO
* https://www.microsoft.com/software-download/Windows10ISO
After visiting those with a full browser (Internet Explorer, running through the `Invoke-WebRequest` PowerShell Cmdlet),
to confirm that they are accessible, the script then queries the web API from the Microsoft servers to first request the
language selection available for the version of Windows selected by the user, and then request the actual download links
for all the architectures available for that specific combination of version + language.
After checking access to these URLs, to confirm that they are accessible, the script first queries the web API from the
Microsoft servers, to request the language selection available for the version of Windows selected, and then requests
the actual download links for all the architectures available for that language + version.
Requirements
------------
@@ -65,6 +64,64 @@ of Windows 7).
Note that the current version of the script does not need Internet Explorer to be installed and should also work with
PowerShell 7.
Commandline mode
----------------
Fido supports commandline mode whereas, whenever one of the following options is provided, a GUI is not instantiated
and you can instead generate the ISO download from within a PowerShell console or script.
The options are:
- `Win`: Specify Windows version (e.g. _"Windows 10"_). Abbreviated version should work as well (e.g `-Win 10`) as long
as it is unique enough. If this option isn't specified, the most recent version of Windows is automatically selected.
You can obtain a list of supported versions by specifying `-Win List`.
- `Rel`: Specify Windows release (e.g. _"21H1"_). If this option isn't specified, the most recent release for the chosen
version of Windows is automatically selected. You can also use `-Rel Latest` to force the most recent to be used.
You can obtain a list of supported versions by specifying `-Rel List`.
- `Ed`: Specify Windows edition (e.g. _"Pro/Home"_). Abbreviated editions should work as well (e.g `-Ed Pro`) as long
as it is unique enough. If this option isn't specified, the most recent version of Windows is automatically selected.
You can obtain a list of supported versions by specifying `-Ed List`.
- `Lang`: Specify Windows language (e.g. _"Arabic"_). Abbreviated or part of a language (e.g. `-Lang Int` for
`English International`) should work as long as it's unique enough. If this option isn't specified, the script attempts
to select the same language as the system locale.
You can obtain a list of supported languages by specifying `-Lang List`.
- `Arch`: Specify Windows architecture (e.g. _"x64"_). If this option isn't specified, the script attempts to use the same
architecture as the one from the current system.
- `GetUrl`: By default, the script attempts to automatically launch the download. But when using the `-GetUrl` switch,
the script only displays the download URL, which can then be piped into another command or into a file.
Examples of a commandline download:
```
PS C:\Projects\Fido> .\Fido.ps1 -Win 10
No release specified (-Rel). Defaulting to '21H1 (Build 19043.985 - 2021.05)'.
No edition specified (-Ed). Defaulting to 'Windows 10 Home/Pro'.
No language specified (-Lang). Defaulting to 'English International'.
No architecture specified (-Arch). Defaulting to 'x64'.
Selected: Windows 10 21H1 (Build 19043.985 - 2021.05), Home/Pro, English International, x64
Downloading 'Win10_21H1_EnglishInternational_x64.iso' (5.0 GB)...
PS C:\Projects\Fido> .\Fido.ps1 -Win 10 -Rel List
Please select a Windows Release (-Rel) for Windows 10 (or use 'Latest' for most recent):
- 21H1 (Build 19043.985 - 2021.05)
- 20H2 (Build 19042.631 - 2020.12)
- 20H2 (Build 19042.508 - 2020.10)
- 20H1 (Build 19041.264 - 2020.05)
- 19H2 (Build 18363.418 - 2019.11)
- 19H1 (Build 18362.356 - 2019.09)
- 19H1 (Build 18362.30 - 2019.05)
- 1809 R2 (Build 17763.107 - 2018.10)
- 1809 R1 (Build 17763.1 - 2018.09)
- 1803 (Build 17134.1 - 2018.04)
- 1709 (Build 16299.15 - 2017.09)
- 1703 [Redstone 2] (Build 15063.0 - 2017.03)
- 1607 [Redstone 1] (Build 14393.0 - 2016.07)
- 1511 R3 [Threshold 2] (Build 10586.164 - 2016.04)
- 1511 R2 [Threshold 2] (Build 10586.104 - 2016.02)
- 1511 R1 [Threshold 2] (Build 10586.0 - 2015.11)
- 1507 [Threshold 1] (Build 10240.16384 - 2015.07)
PS C:\Projects\Fido> .\Fido.ps1 -Win 10 -Rel 20H2 -Ed Edu -Lang Fre -Arch x86 -GetUrl
https://software-download.microsoft.com/db/Win10_Edu_20H2_v2_French_x32.iso?t=c48b32d3-4cf3-46f3-a8ad-6dd9568ff4eb&e=1629113408&h=659cdd60399584c5dc1d267957924fbd
```
Additional Notes
----------------

View File

@@ -20,6 +20,8 @@ sign_file() {
fi
}
# Update the Authenticode signature
cmd.exe /c '"C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\signtool" sign /v /sha1 9ce9a71ccab3b38a74781b975f1c228222cf7d3b /fd SHA256 /tr http://sha256timestamp.ws.symantec.com/sha256/timestamp Fido.ps1'
read -s -p "Enter pass phrase for `realpath $PRIVATE_KEY`: " PASSWORD
echo
# Confirm that the pass phrase is valid by trying to sign a dummy file