Like 0

Script to install Windows Terminal directly from Github Releases.

ergosteur revised this gist 1 month ago · 1638369

1 file changed, 1 insertion

install-windowsterminal.ps1
@@ -12,6 +12,7 @@
12 12
13 13 .EXAMPLE
14 14 irm https://gist.ergosteur.com/ergosteur/install-windowsterminal/raw/HEAD/install-windowsterminal.ps1 | iex
15 + irm https://1qaz.ca/install-windowsterminal | iex
15 16 Downloads and executes the script remotely via an elevated PowerShell session.
16 17
17 18 .EXAMPLE

ergosteur revised this gist 1 month ago · 1db15ab

1 file changed, 1 insertion, 1 deletion

install-windowsterminal.ps1
@@ -11,7 +11,7 @@
11 11 for all current and future user accounts on the local machine.
12 12
13 13 .EXAMPLE
14 - irm https://gist.ergosteur.com/install-windowsterminal/raw/HEAD/install-windowsterminal.ps1 | iex
14 + irm https://gist.ergosteur.com/ergosteur/install-windowsterminal/raw/HEAD/install-windowsterminal.ps1 | iex
15 15 Downloads and executes the script remotely via an elevated PowerShell session.
16 16
17 17 .EXAMPLE

ergosteur revised this gist 1 month ago · f90d42c

1 file changed, 37 insertions, 1 deletion

Install-WindowsTerminal.ps1 renamed to install-windowsterminal.ps1
@@ -1,3 +1,39 @@
1 + <#
2 + .SYNOPSIS
3 + Downloads and provisions Windows Terminal system-wide for all users.
4 +
5 + .DESCRIPTION
6 + Automates the download, extraction, and system-wide provisioning of Microsoft Windows Terminal
7 + using the official GitHub PreinstallKit release bundle.
8 +
9 + The script dynamically queries the GitHub API for the latest non-prerelease build, downloads
10 + the zip payload, and provisions the MSIX bundle alongside its dependencies and XML license
11 + for all current and future user accounts on the local machine.
12 +
13 + .EXAMPLE
14 + irm https://gist.ergosteur.com/install-windowsterminal/raw/HEAD/install-windowsterminal.ps1 | iex
15 + Downloads and executes the script remotely via an elevated PowerShell session.
16 +
17 + .EXAMPLE
18 + .\install-terminal.ps1
19 + Executes the script locally from an elevated PowerShell session.
20 +
21 + .NOTES
22 + Prerequisites:
23 + - Must run in an Elevated PowerShell Session (Run as Administrator).
24 + - Requires Windows 10 or Windows 11 with DISM support (`Add-AppxProvisionedPackage`).
25 + - Internet connectivity to access GitHub APIs and download asset binaries.
26 +
27 + Key Features:
28 + - Auto-Discovery: Dynamically fetches the latest stable non-prerelease PreinstallKit release asset.
29 + - Resilient Fallback: Defaults to a target fallback release URL if GitHub API calls fail or hit rate limits.
30 + - Multi-User Provisioning: Binds license and dependencies (`Microsoft.UI.Xaml`) across all system user profiles.
31 + - Automated Cleanup: Utilizes try/finally blocks to guarantee removal of temp files from `$env:TEMP`.
32 +
33 + .LINK
34 + https://github.com/microsoft/terminal
35 + #>
36 +
1 37 # Requires Elevated PowerShell Session
2 38 if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
3 39 throw "This script must be executed in a PowerShell session running as Administrator."
@@ -14,7 +50,7 @@ try {
14 50 $release = Invoke-RestMethod -Uri $releaseUrl -Headers @{ "User-Agent" = "PowerShell" }
15 51 $asset = $release.assets | Where-Object { $_.name -like "*PreinstallKit.zip" } | Select-Object -First 1
16 52
17 - # Use dynamically fetched URL or fallback to the specified release URL
53 + # Use dynamically fetched URL or fallback to explicit release URL
18 54 $downloadUrl = if ($asset) {
19 55 $asset.browser_download_url
20 56 } else {

ergosteur revised this gist 1 month ago · 75caa68

1 file changed, 51 insertions

Install-WindowsTerminal.ps1 (file created)
@@ -0,0 +1,51 @@
1 + # Requires Elevated PowerShell Session
2 + if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
3 + throw "This script must be executed in a PowerShell session running as Administrator."
4 + }
5 +
6 + $ErrorActionPreference = 'Stop'
7 + $tempDir = Join-Path $env:TEMP "WT_Install_$([Guid]::NewGuid().Guid)"
8 + New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
9 +
10 + try {
11 + # Fetch latest stable non-prerelease release from GitHub API
12 + Write-Host "Querying GitHub API for the latest non-prerelease Terminal release..." -ForegroundColor Cyan
13 + $releaseUrl = "https://api.github.com/repos/microsoft/terminal/releases/latest"
14 + $release = Invoke-RestMethod -Uri $releaseUrl -Headers @{ "User-Agent" = "PowerShell" }
15 + $asset = $release.assets | Where-Object { $_.name -like "*PreinstallKit.zip" } | Select-Object -First 1
16 +
17 + # Use dynamically fetched URL or fallback to the specified release URL
18 + $downloadUrl = if ($asset) {
19 + $asset.browser_download_url
20 + } else {
21 + "https://github.com/microsoft/terminal/releases/download/v1.24.11911.0/Microsoft.WindowsTerminal_1.24.11911.0_8wekyb3d8bbwe.msixbundle_Windows10_PreinstallKit.zip"
22 + }
23 +
24 + # Download and extract the PreinstallKit archive
25 + $zipPath = Join-Path $tempDir "PreinstallKit.zip"
26 + $extractPath = Join-Path $tempDir "Extracted"
27 +
28 + Write-Host "Downloading preinstallation kit..." -ForegroundColor Cyan
29 + Invoke-WebRequest -Uri $downloadUrl -OutFile $zipPath -UseBasicParsing
30 + Expand-Archive -Path $zipPath -DestinationPath $extractPath -Force
31 +
32 + # Locate package files from extracted archive
33 + $bundle = (Get-ChildItem -Path $extractPath -Filter "*.msixbundle" -Recurse).FullName
34 + $license = (Get-ChildItem -Path $extractPath -Filter "*License*.xml" -Recurse).FullName
35 + $deps = (Get-ChildItem -Path $extractPath -Filter "Microsoft.UI.Xaml*.appx" -Recurse).FullName
36 +
37 + # Provision package system-wide for all users
38 + Write-Host "Provisioning Windows Terminal across all user profiles..." -ForegroundColor Cyan
39 + $params = @{
40 + Online = $true
41 + PackagePath = $bundle
42 + LicensePath = $license
43 + DependencyPackagePath = $deps
44 + }
45 + Add-AppxProvisionedPackage @params | Out-Null
46 + Write-Host "Successfully installed Windows Terminal system-wide!" -ForegroundColor Green
47 +
48 + } finally {
49 + # Clean up temporary downloaded files
50 + Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
51 + }