Ordres per instal·lar Ubuntu sense preguntes, desinstal·lar-lo i detectar-lo des d’eines de desplegament. Només es mostra una ordre quan és segura: la que indica el manifest o el valor per defecte documentat de la tecnologia de l’instal·lador.
Guia relacionada: Instal·lació silenciosa: MSI, NSIS, Inno Setup · Desinstal·lar un programa amb el registre o PowerShell
Amb 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 --silentPer instal·lador
64 bits · APPX
Instal·lació silenciosa
Add-AppxPackage -Path Ubuntu2204-220117.appxDesinstal·lar
Get-AppxPackage -Name CanonicalGroupLimited.Ubuntu | Remove-AppxPackageARM64 · APPX
Instal·lació silenciosa
Add-AppxPackage -Path Ubuntu2204-220117_ARM64.appxDesinstal·lar
Get-AppxPackage -Name CanonicalGroupLimited.Ubuntu | Remove-AppxPackagePowerShell: baixar, verificar, instal·lar
Baixa el fitxer oficial, en comprova l’SHA256 i l’instal·la en mode silenciós.
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