Add Appx built-in app removal script
This commit is contained in:
+16
-3
@@ -20,7 +20,8 @@ Petite boîte à outils Windows pour installer des packs de logiciels libres ave
|
||||
| Chemin | Rôle |
|
||||
| --- | --- |
|
||||
| [`powershell/libres-softwares-install.ps1`](./powershell/libres-softwares-install.ps1) | Installateur interactif pour une liste de logiciels sélectionnés. |
|
||||
| [`powershell/Winget-Remove-BuiltInApps.ps1`](./powershell/Winget-Remove-BuiltInApps.ps1) | Suppression de certaines applications Windows intégrées pour l'utilisateur courant. |
|
||||
| [`powershell/Winget-Remove-BuiltInApps.ps1`](./powershell/Winget-Remove-BuiltInApps.ps1) | Suppression de certaines applications Windows intégrées pour l'utilisateur courant avec winget. |
|
||||
| [`powershell/Remove-BuiltInApps.ps1`](./powershell/Remove-BuiltInApps.ps1) | Suppression de certaines applications Appx intégrées sans winget, y compris les packages provisionnés pour les nouveaux utilisateurs. |
|
||||
| [`winget/libre-soft-start-pack.yaml`](./winget/libre-soft-start-pack.yaml) | Pack automatisé de départ : Firefox ESR, 7-Zip et VLC. |
|
||||
| [`winget/libre-soft-base-libreoffice.yaml`](./winget/libre-soft-base-libreoffice.yaml) | Pack de départ avec LibreOffice. |
|
||||
| [`winget/libre-soft-base-onlyoffice.yaml`](./winget/libre-soft-base-onlyoffice.yaml) | Pack de départ avec ONLYOFFICE. |
|
||||
@@ -86,13 +87,25 @@ winget configure --file .\winget\libre-soft-start-pack.yaml --accept-configurati
|
||||
|
||||
## Supprimer des Applications Intégrées
|
||||
|
||||
Le script de nettoyage désinstalle certaines applications Windows pour l'utilisateur courant.
|
||||
Utilise le script de nettoyage Appx pour supprimer certaines applications intégrées sans winget et éviter leur provisionnement pour les nouveaux utilisateurs.
|
||||
|
||||
```powershell
|
||||
powershell -ExecutionPolicy Bypass -File .\powershell\Remove-BuiltInApps.ps1
|
||||
```
|
||||
|
||||
OneDrive n'est généralement pas un package Appx. Pour appeler aussi le programme de désinstallation intégré de OneDrive, ajoute `-IncludeOneDrive` :
|
||||
|
||||
```powershell
|
||||
powershell -ExecutionPolicy Bypass -File .\powershell\Remove-BuiltInApps.ps1 -IncludeOneDrive
|
||||
```
|
||||
|
||||
L'ancien script basé sur winget reste disponible, mais il ne cible que l'utilisateur courant :
|
||||
|
||||
```powershell
|
||||
powershell -ExecutionPolicy Bypass -File .\powershell\Winget-Remove-BuiltInApps.ps1
|
||||
```
|
||||
|
||||
Les applications visées incluent des composants Xbox, Outlook for Windows, Hub de commentaires, OneDrive, Teams, Microsoft To Do, des applications Bing, Clipchamp et des packages intégrés associés.
|
||||
Les applications visées incluent des composants Xbox, Outlook for Windows, Hub de commentaires, Power Automate, Sticky Notes, Météo, Teams, Microsoft To Do, des applications Bing, Clipchamp, Windows Web Experience Pack et des packages intégrés associés.
|
||||
|
||||
## Note de Maintenance
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@ Small Windows toolkit to install libre software packs with `winget` and remove s
|
||||
| Path | Purpose |
|
||||
| --- | --- |
|
||||
| [`powershell/libres-softwares-install.ps1`](./powershell/libres-softwares-install.ps1) | Interactive installer for a curated list of applications. |
|
||||
| [`powershell/Winget-Remove-BuiltInApps.ps1`](./powershell/Winget-Remove-BuiltInApps.ps1) | Removes selected built-in Windows applications for the current user. |
|
||||
| [`powershell/Winget-Remove-BuiltInApps.ps1`](./powershell/Winget-Remove-BuiltInApps.ps1) | Removes selected built-in Windows applications for the current user with winget. |
|
||||
| [`powershell/Remove-BuiltInApps.ps1`](./powershell/Remove-BuiltInApps.ps1) | Removes selected built-in Appx applications without winget, including provisioned packages for new users. |
|
||||
| [`winget/libre-soft-start-pack.yaml`](./winget/libre-soft-start-pack.yaml) | Automated starter pack: Firefox ESR, 7-Zip and VLC. |
|
||||
| [`winget/libre-soft-base-libreoffice.yaml`](./winget/libre-soft-base-libreoffice.yaml) | Starter pack plus LibreOffice. |
|
||||
| [`winget/libre-soft-base-onlyoffice.yaml`](./winget/libre-soft-base-onlyoffice.yaml) | Starter pack plus ONLYOFFICE. |
|
||||
@@ -82,13 +83,25 @@ winget configure --file .\winget\libre-soft-start-pack.yaml --accept-configurati
|
||||
|
||||
## Remove Built-In Apps
|
||||
|
||||
The cleanup script uninstalls selected Windows applications for the current user.
|
||||
Use the Appx cleanup script when you want to remove selected built-in applications without winget and prevent them from being provisioned for newly created users.
|
||||
|
||||
```powershell
|
||||
powershell -ExecutionPolicy Bypass -File .\powershell\Remove-BuiltInApps.ps1
|
||||
```
|
||||
|
||||
OneDrive is not an Appx package on most Windows installations. To also call the built-in OneDrive uninstaller, pass `-IncludeOneDrive`:
|
||||
|
||||
```powershell
|
||||
powershell -ExecutionPolicy Bypass -File .\powershell\Remove-BuiltInApps.ps1 -IncludeOneDrive
|
||||
```
|
||||
|
||||
The older winget-based cleanup script is still available, but it only targets the current user:
|
||||
|
||||
```powershell
|
||||
powershell -ExecutionPolicy Bypass -File .\powershell\Winget-Remove-BuiltInApps.ps1
|
||||
```
|
||||
|
||||
Targeted applications include Xbox components, Outlook for Windows, Feedback Hub, OneDrive, Teams, Microsoft To Do, Bing apps, Clipchamp and related built-in packages.
|
||||
Targeted applications include Xbox components, Outlook for Windows, Feedback Hub, Power Automate, Sticky Notes, Weather, Teams, Microsoft To Do, Bing apps, Clipchamp, Windows Web Experience Pack and related built-in packages.
|
||||
|
||||
## Maintenance Note
|
||||
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
# Requires running as administrator
|
||||
# Removes selected built-in Appx packages without winget.
|
||||
# Installed packages are removed for existing users when supported.
|
||||
# Provisioned packages are removed so they are not installed for new users.
|
||||
|
||||
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "High")]
|
||||
param(
|
||||
[switch]$IncludeOneDrive
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Continue"
|
||||
|
||||
$IsAdministrator = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(
|
||||
[Security.Principal.WindowsBuiltInRole]::Administrator
|
||||
)
|
||||
|
||||
if (-not $IsAdministrator) {
|
||||
Write-Error "This script must be run from an administrator PowerShell session."
|
||||
exit 1
|
||||
}
|
||||
|
||||
$PackageNamePatterns = @(
|
||||
"MicrosoftWindows.Client.WebExperience",
|
||||
"Microsoft.OutlookForWindows",
|
||||
"Microsoft.WindowsFeedbackHub",
|
||||
"Microsoft.XboxApp",
|
||||
"Microsoft.GamingApp",
|
||||
"Microsoft.Xbox.TCUI",
|
||||
"Microsoft.XboxGameOverlay",
|
||||
"Microsoft.XboxGamingOverlay",
|
||||
"Microsoft.XboxIdentityProvider",
|
||||
"Microsoft.XboxSpeechToTextOverlay",
|
||||
"Microsoft.PowerAutomateDesktop",
|
||||
"Microsoft.MicrosoftStickyNotes",
|
||||
"Microsoft.BingWeather",
|
||||
"MSTeams",
|
||||
"MicrosoftTeams",
|
||||
"Microsoft.Todos",
|
||||
"Microsoft.BingSearch",
|
||||
"Microsoft.BingNews",
|
||||
"Clipchamp.Clipchamp"
|
||||
)
|
||||
|
||||
function Remove-InstalledAppxPackage {
|
||||
param(
|
||||
[string]$Pattern
|
||||
)
|
||||
|
||||
$Packages = Get-AppxPackage -AllUsers -Name $Pattern -ErrorAction SilentlyContinue
|
||||
|
||||
if (-not $Packages) {
|
||||
Write-Host "No installed Appx package found for: $Pattern" -ForegroundColor DarkGray
|
||||
return
|
||||
}
|
||||
|
||||
foreach ($Package in $Packages) {
|
||||
$Target = "$($Package.Name) [$($Package.PackageFullName)]"
|
||||
Write-Host "Removing installed package: $Target" -ForegroundColor Cyan
|
||||
|
||||
if ($PSCmdlet.ShouldProcess($Target, "Remove installed Appx package")) {
|
||||
try {
|
||||
Remove-AppxPackage -Package $Package.PackageFullName -AllUsers -ErrorAction Stop
|
||||
Write-Host "Removed installed package: $($Package.Name)" -ForegroundColor Green
|
||||
}
|
||||
catch {
|
||||
Write-Warning "Failed to remove installed package $($Package.Name): $_"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Remove-ProvisionedAppxPackage {
|
||||
param(
|
||||
[string]$Pattern
|
||||
)
|
||||
|
||||
$ProvisionedPackages = Get-AppxProvisionedPackage -Online |
|
||||
Where-Object {
|
||||
$_.DisplayName -like $Pattern -or
|
||||
$_.PackageName -like "$Pattern*"
|
||||
}
|
||||
|
||||
if (-not $ProvisionedPackages) {
|
||||
Write-Host "No provisioned Appx package found for: $Pattern" -ForegroundColor DarkGray
|
||||
return
|
||||
}
|
||||
|
||||
foreach ($Package in $ProvisionedPackages) {
|
||||
$Target = "$($Package.DisplayName) [$($Package.PackageName)]"
|
||||
Write-Host "Removing provisioned package: $Target" -ForegroundColor Cyan
|
||||
|
||||
if ($PSCmdlet.ShouldProcess($Target, "Remove provisioned Appx package for future users")) {
|
||||
try {
|
||||
Remove-AppxProvisionedPackage -Online -PackageName $Package.PackageName -ErrorAction Stop | Out-Null
|
||||
Write-Host "Removed provisioned package: $($Package.DisplayName)" -ForegroundColor Green
|
||||
}
|
||||
catch {
|
||||
Write-Warning "Failed to remove provisioned package $($Package.DisplayName): $_"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Remove-OneDrive {
|
||||
$Installers = @(
|
||||
"$env:SystemRoot\System32\OneDriveSetup.exe",
|
||||
"$env:SystemRoot\SysWOW64\OneDriveSetup.exe"
|
||||
)
|
||||
|
||||
foreach ($Installer in $Installers) {
|
||||
if (-not (Test-Path $Installer)) {
|
||||
continue
|
||||
}
|
||||
|
||||
Write-Host "Removing OneDrive with: $Installer" -ForegroundColor Cyan
|
||||
|
||||
if ($PSCmdlet.ShouldProcess($Installer, "Uninstall OneDrive")) {
|
||||
try {
|
||||
Start-Process -FilePath $Installer -ArgumentList "/uninstall" -Wait -NoNewWindow
|
||||
Write-Host "OneDrive uninstall command completed." -ForegroundColor Green
|
||||
}
|
||||
catch {
|
||||
Write-Warning "Failed to uninstall OneDrive with $Installer`: $_"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Removing selected built-in Appx applications..." -ForegroundColor Cyan
|
||||
Write-Host "This can affect existing users and the default package set for new users." -ForegroundColor Yellow
|
||||
Write-Host ""
|
||||
|
||||
foreach ($Pattern in $PackageNamePatterns) {
|
||||
Remove-InstalledAppxPackage -Pattern $Pattern
|
||||
Remove-ProvisionedAppxPackage -Pattern $Pattern
|
||||
Write-Host ""
|
||||
}
|
||||
|
||||
if ($IncludeOneDrive) {
|
||||
Remove-OneDrive
|
||||
}
|
||||
else {
|
||||
Write-Host "OneDrive was not removed. Re-run with -IncludeOneDrive to call the built-in OneDrive uninstaller." -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Done. Restart Windows before creating new user profiles." -ForegroundColor Green
|
||||
Reference in New Issue
Block a user