From ab27588b5cbdfc5b7ad42eb9ad9ec6eee800d2e9 Mon Sep 17 00:00:00 2001 From: Olivier Date: Sat, 31 Jan 2026 09:50:12 +0100 Subject: [PATCH] Actualiser powershell/Remove-BuiltInApps.ps1 --- powershell/Remove-BuiltInApps.ps1 | 34 +++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/powershell/Remove-BuiltInApps.ps1 b/powershell/Remove-BuiltInApps.ps1 index 42abbba..923c2cc 100644 --- a/powershell/Remove-BuiltInApps.ps1 +++ b/powershell/Remove-BuiltInApps.ps1 @@ -1,6 +1,6 @@ <# .SYNOPSIS - Remove selected built-in Windows apps for current and new users. + Remove selected built-in Windows apps for current user, all existing users, and prevent them for new users. .DESCRIPTION Removes the following apps: @@ -15,8 +15,10 @@ - Weather - Microsoft Teams - OneDrive - The script removes both the installed package for the current user - and the provisioned package for all new users. + The script removes: + - Provisioned packages (prevents reinstallation for new users) + - Packages for all existing users + - Packages for the current user .NOTES Must be run as Administrator @@ -60,6 +62,30 @@ foreach ($App in $AppsToRemove) { } } +# Get all user profiles except system profiles +$UserProfiles = Get-ChildItem C:\Users | Where-Object { $_.Name -notin @("Public","Default","Default User","All Users") } + +# Remove apps for all existing users +Write-Host "`nRemoving apps for all existing users..." -ForegroundColor Cyan +foreach ($UserProfile in $UserProfiles) { + $Username = $UserProfile.Name + Write-Host "`nProcessing user: $Username" -ForegroundColor Cyan + + foreach ($App in $AppsToRemove) { + try { + $Pkg = Get-AppxPackage -User $Username -Name $App.Package + if ($Pkg) { + $Pkg | Remove-AppxPackage -User $Username -ErrorAction Stop + Write-Host "✔ Removed $($App.Name) from $Username" -ForegroundColor Green + } else { + Write-Host "$($App.Name) not installed for $Username" -ForegroundColor Yellow + } + } catch { + Write-Warning "Failed to remove $($App.Name) for $Username: $_" + } + } +} + # Remove apps for current user Write-Host "`nRemoving apps for current user..." -ForegroundColor Cyan foreach ($App in $AppsToRemove) { @@ -76,4 +102,4 @@ foreach ($App in $AppsToRemove) { } } -Write-Host "`nAll tasks completed." -ForegroundColor Cyan \ No newline at end of file +Write-Host "`nAll tasks completed for all users and provisioned packages." -ForegroundColor Cyan