Install-Microsoft-Store.ps1 - Add use existing files mode

Adds parameter to use previously downloaded installer files.
pull/13/head^2
ThioJoe 2026-02-12 13:10:24 -07:00
parent 681ea4182d
commit 420d6e8508
No known key found for this signature in database
GPG Key ID: 2E328FE64CC3898C
1 changed files with 230 additions and 200 deletions

View File

@ -4,17 +4,40 @@
# Author: ThioJoe # Author: ThioJoe
# Repo Url: https://github.com/ThioJoe/Windows-Sandbox-Tools # Repo Url: https://github.com/ThioJoe/Windows-Sandbox-Tools
# Last Updated: August 10, 2025 # Last Updated: February 12, 2026
param( param(
# Optional switch to output the generated XML files to the working directory # Optional switch to output the generated XML files to the working directory
[switch]$debugSaveFiles, [switch]$debugSaveFiles,
# Optional switch to skip the installation of Microsoft Store, but still download the files # Optional switch to skip the installation of Microsoft Store, but still download the files
[switch]$noInstall, [switch]$noInstall,
# Optional switch to skip the download and install, but still show the packages found # Optional switch to skip the download and install, but still show the packages found
[switch]$noDownload [switch]$noDownload,
# Optional path to a local directory containing the installation files. If provided, the download steps will be skipped.
# - Just copy the entire "MSStore Install" folder with the files the script normally downloads, and put it in your mounted folder to avoid having to re-download it.
# - You can find the "MSStore Install" folder in the "Downloads" folder.
# - Make sure to use the mounted path from the perspective of within the sandbox.
[string]$ExistingInstallerFilesPath
) )
# --- Parameter Usage Examples ---
# Standard run (Download & Install):
# .\Install-Microsoft-Store.ps1
#
# Install from existing files instead of downloading:
# .\Install-Microsoft-Store.ps1 -ExistingInstallerFilesPath "C:\Users\WDAGUtilityAccount\Desktop\HostShared\MSStore Install"
#
# Download only (Don't Install):
# .\Install-Microsoft-Store.ps1 -noInstall
#
# Debug mode (Save SOAP XML logs to disk):
# .\Install-Microsoft-Store.ps1 -debugSaveFiles
# =======================================================
# --- Configuration --- # --- Configuration ---
# Note: These defaults should work for the regular current build of Microsoft Store, but I haven't tested using any of the other values. So fetching insider builds of MS Store (if any) might not work. # Note: These defaults should work for the regular current build of Microsoft Store, but I haven't tested using any of the other values. So fetching insider builds of MS Store (if any) might not work.
$flightRing = "Retail" # Apparently accepts 'Retail', 'Internal', and 'External' $flightRing = "Retail" # Apparently accepts 'Retail', 'Internal', and 'External'
@ -43,21 +66,26 @@ $subfolderName = "MSStore Install"
# Category ID for the Microsoft Store app package # Category ID for the Microsoft Store app package
$storeCategoryId = "64293252-5926-453c-9494-2d4021f1c78d" $storeCategoryId = "64293252-5926-453c-9494-2d4021f1c78d"
# Combine them to create the full working directory path if ($ExistingInstallerFilesPath) {
$workingDir = Join-Path -Path $userDownloadsFolder -ChildPath $subfolderName if (Test-Path -Path $ExistingInstallerFilesPath) {
$LogDirectory = Join-Path -Path $workingDir -ChildPath "Logs" $workingDir = $ExistingInstallerFilesPath
Write-Host "Using local source path: $workingDir" -ForegroundColor Yellow
} else {
Write-Error "The specified local source path does not exist: $ExistingInstallerFilesPath"
return
}
} else {
# Combine them to create the full working directory path
$workingDir = Join-Path -Path $userDownloadsFolder -ChildPath $subfolderName
# Create the directory if it doesn't exist # Create the directory if it doesn't exist
if (-not (Test-Path -Path $workingDir)) { if (-not (Test-Path -Path $workingDir)) {
New-Item -Path $workingDir -ItemType Directory -Force | Out-Null New-Item -Path $workingDir -ItemType Directory -Force | Out-Null
}
} }
If ($debugSaveFiles) { If ($debugSaveFiles) {
# Create a subdirectory for logs if it doesn't exist Write-Host "All files (logs, downloads) will be saved to: '$workingDir'" -ForegroundColor Yellow
if (-not (Test-Path -Path $LogDirectory)) {
New-Item -Path $LogDirectory -ItemType Directory -Force | Out-Null
}
Write-Host "All files (logs, downloads) will be saved to: '$LogDirectory'" -ForegroundColor Yellow
} }
# --- XML Templates --- # --- XML Templates ---
@ -185,6 +213,7 @@ $headers = @{ "Content-Type" = "application/soap+xml; charset=utf-8" }
$baseUri = "https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx" $baseUri = "https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx"
try { try {
if (-not $ExistingInstallerFilesPath) {
# Step 1: Get Cookie # Step 1: Get Cookie
Write-Host "Step 1: Getting authentication cookie..." Write-Host "Step 1: Getting authentication cookie..."
$cookieRequestPayload = $cookieXmlTemplate $cookieRequestPayload = $cookieXmlTemplate
@ -384,6 +413,7 @@ try {
Write-Host "An error occurred during the filtering or downloading phase:" -ForegroundColor Red Write-Host "An error occurred during the filtering or downloading phase:" -ForegroundColor Red
Write-Host $_.Exception.ToString() Write-Host $_.Exception.ToString()
} }
}
If ($noDownload) { If ($noDownload) {
Write-Host "Skipping download step because of -noDownload switch." -ForegroundColor Yellow Write-Host "Skipping download step because of -noDownload switch." -ForegroundColor Yellow