While updating our Windows 10 images to the anniversary update (1607), I noticed that all the bloat I had already removed was added back. So I took this opportunity to brush up on some more Powershell and create a script that could help some other folks with the same issue!
Note:
- Microsoft.WindowsCommunicationsApps allows for the taskbar calendar integration
- Microsoft.Windows.Photos was left alone because they removed the old photo viewer (Fix)
- Microsoft.WindowsCalculator was left alone because they removed the old calc
- Microsoft.StorePurchaseApp allows for in-app purchase
- NEVER remove Microsoft.WindowsStore, no option to restore.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
#region Elevate Powershell if needed $myWindowsID=[System.Security.Principal.WindowsIdentity]::GetCurrent() $myWindowsPrincipal=new-object System.Security.Principal.WindowsPrincipal($myWindowsID) $adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator if ($myWindowsPrincipal.IsInRole($adminRole)) { clear-host } else { $newProcess = new-object System.Diagnostics.ProcessStartInfo "PowerShell"; $newProcess.Arguments = "& '" + $myInvocation.MyCommand.Definition + "'"; $newProcess.Verb = "runas"; [System.Diagnostics.Process]::Start($newProcess); exit } #endregion #region Appx to be removed $Remove = "Microsoft.3DBuilder", "Microsoft.BingWeather", "Microsoft.Getstarted", "Microsoft.Messaging", "Microsoft.MicrosoftOfficeHub", "Microsoft.MicrosoftSolitaireCollection", "Microsoft.MicrosoftStickyNotes", "Microsoft.Office.OneNote" , "Microsoft.Office.Sway", "Microsoft.OneConnect", "Microsoft.People", "Microsoft.SkypeApp", "Microsoft.WindowsAlarms", "Microsoft.WindowsCamera", "Microsoft.WindowsFeedbackHub" , "Microsoft.WindowsMaps" , "Microsoft.XboxApp", "Microsoft.XboxIdentityProvider", "Microsoft.ZuneMusic", "Microsoft.ZuneVideo" #endregion #region Get list of currently installed and provisioned Appx packages $AllInstalled = Get-AppxPackage -AllUsers | Foreach {$_.Name} $AllProvisioned = Get-ProvisionedAppxPackage -Online | Foreach {$_.DisplayName} #endregion #region Remove Appx Packages Write-Host "`n" Write-Host '#####################################' -ForegroundColor Green Write-Host -NoNewline '#' -ForegroundColor Green Write-Host -NoNewline ' ' Write-Host -NoNewline "Appx Packages" -ForegroundColor White Write-Host -NoNewline ' ' Write-Host '#' -ForegroundColor Green Write-Host '#####################################' -ForegroundColor Green Write-Host "`n" Foreach($Appx in $Remove){ $error.Clear() If($AllInstalled -like "*$Appx*"){ Try{ #Turn off the progress bar $ProgressPreference = 'silentlyContinue' Get-AppxPackage -Name $Appx | Remove-AppxPackage #Turn on the progress bar $ProgressPreference = 'Continue' } Catch{ $ErrorMessage = $_.Exception.Message $FailedItem = $_.Exception.ItemName Write-Host "There was an error removing Appx:" Write-Host $ErrorMessage Write-Host $FailedItem } If(!$error){ Write-Host "Removed Appx: $Appx" } } Else{ Write-Host "Appx Package not installed: $Appx" } } #endregion #region Remove Provisioned Appx Packages Write-Host "`n" Write-Host '#####################################' -ForegroundColor Green Write-Host -NoNewline '#' -ForegroundColor Green Write-Host -NoNewline ' ' Write-Host -NoNewline "Provisioned Appx Packages" -ForegroundColor White Write-Host -NoNewline ' ' Write-Host '#' -ForegroundColor Green Write-Host '#####################################' -ForegroundColor Green Write-Host "`n" Foreach($Appx in $Remove){ $error.Clear() If($AllProvisioned -like "*$Appx*"){ Try{ Get-ProvisionedAppxPackage -Online | where {$_.DisplayName -eq $Appx} | Remove-ProvisionedAppxPackage -Online | Out-Null } Catch{ $ErrorMessage = $_.Exception.Message $FailedItem = $_.Exception.ItemName Write-Host "There was an error removing Provisioned Appx:" Write-Host $ErrorMessage Write-Host $FailedItem } If(!$error){ Write-Host "Removed Provisioned Appx: $Appx" } } Else{ Write-Host "Provisioned Appx Package not installed: $Appx" } } #endregion Write-Host "`n" Write-Host {"Press any key to continue ..."} $x = $host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown') Exit |