Ubuntuを確認画面なしでインストール・アンインストールし、展開ツールで検出するためのコマンドです。マニフェストの記載か、インストーラー技術の既定値として確実なコマンドだけを表示しています。
関連ガイド: サイレントインストールのオプション一覧 · レジストリとPowerShellでアンインストールする方法
wingetを使う
PowerShell
winget install --id Canonical.Ubuntu -e --silent --accept-package-agreements --accept-source-agreementswinget upgrade --id Canonical.Ubuntu -e --silentwinget uninstall --id Canonical.Ubuntu -e --silentインストーラー別
64ビット · APPX
サイレントインストール
Add-AppxPackage -Path Ubuntu2204-220117.appxアンインストール
Get-AppxPackage -Name CanonicalGroupLimited.Ubuntu | Remove-AppxPackageARM64 · APPX
サイレントインストール
Add-AppxPackage -Path Ubuntu2204-220117_ARM64.appxアンインストール
Get-AppxPackage -Name CanonicalGroupLimited.Ubuntu | Remove-AppxPackagePowerShell:ダウンロード・検証・インストール
公式ファイルをダウンロードし、SHA256を検証してからサイレントインストールします。
install-ubuntu.ps1
$url = 'https://publicwsldistros.blob.core.windows.net/wsldistrostorage/Ubuntu2204-220117.appx'
$sha256 = '5A09BC002F2F5281D97C5FDC8F02D241FBCDAA5B39590D9474F5297BB14D5EE3'
$file = Join-Path $env:TEMP 'Ubuntu2204-220117.appx'
Invoke-WebRequest -Uri $url -OutFile $file -UseBasicParsing
if ((Get-FileHash $file -Algorithm SHA256).Hash -ne $sha256) { throw 'SHA256 mismatch' }
Add-AppxPackage -Path $file install-ubuntu.ps1
$url = 'https://publicwsldistros.blob.core.windows.net/wsldistrostorage/Ubuntu2204-220117_ARM64.appx'
$sha256 = '5B796275EE9A5A42787055F72E265060F5CC502C4874E88FEB81A34E96074EB7'
$file = Join-Path $env:TEMP 'Ubuntu2204-220117_ARM64.appx'
Invoke-WebRequest -Uri $url -OutFile $file -UseBasicParsing
if ((Get-FileHash $file -Algorithm SHA256).Hash -ne $sha256) { throw 'SHA256 mismatch' }
Add-AppxPackage -Path $file