From 58cad70b1e22c5993025ffd33d156aa0c2286eba Mon Sep 17 00:00:00 2001 From: TheTaylorLee <53202926+TheTaylorLee@users.noreply.github.com> Date: Thu, 12 Dec 2024 11:59:35 -0600 Subject: [PATCH] func: remove-storeapps --- .../ChangeLog.md | 3 +- .../Public/Get-EndpointManagement.ps1 | 2 +- .../Public/Remove-StoreApps.ps1 | 81 +++++++++++++------ 3 files changed, 59 insertions(+), 27 deletions(-) diff --git a/modules/AdminToolbox.EndpointManagement/ChangeLog.md b/modules/AdminToolbox.EndpointManagement/ChangeLog.md index efabd50c..08942272 100644 --- a/modules/AdminToolbox.EndpointManagement/ChangeLog.md +++ b/modules/AdminToolbox.EndpointManagement/ChangeLog.md @@ -247,4 +247,5 @@ * **4.11.0.17** CI Maintenance Release * **4.11.0.18** CI Maintenance Release * **4.11.0.19** CI Maintenance Release -* **4.11.0.20** CI Maintenance Release \ No newline at end of file +* **4.11.0.20** CI Maintenance Release +* **4.12.0.0** Reworked Remove-Storeapps to be more flexible. \ No newline at end of file diff --git a/modules/AdminToolbox.EndpointManagement/Public/Get-EndpointManagement.ps1 b/modules/AdminToolbox.EndpointManagement/Public/Get-EndpointManagement.ps1 index 5b7eaa5d..06422bd2 100644 --- a/modules/AdminToolbox.EndpointManagement/Public/Get-EndpointManagement.ps1 +++ b/modules/AdminToolbox.EndpointManagement/Public/Get-EndpointManagement.ps1 @@ -31,7 +31,7 @@ function Get-EndpointManagement { Write-Host "Join-Domain ..Joins Endpoint to a Domain" -ForegroundColor cyan Write-Host "Mount-ProfileRegistry ..Mounts local users registry hive" -ForegroundColor cyan Write-Host "Remove-Shortcuts ..Removes Desktop Shortcuts" -ForegroundColor cyan - Write-Host "Remove-StoreApps ..Removes crap store apps" -ForegroundColor cyan + Write-Host "Remove-StoreApps ..Remove an array of MS store apps" -ForegroundColor cyan Write-Host "Remove-Tiles ..Removes start menu tiles" -ForegroundColor cyan Write-Host "Repair-DomainJoin ..Repairs lost Domain Membership" -ForegroundColor cyan Write-Host "Reset-EndpointPassword ..Reset the endpoints domain password to repair trust" -ForegroundColor cyan diff --git a/modules/AdminToolbox.EndpointManagement/Public/Remove-StoreApps.ps1 b/modules/AdminToolbox.EndpointManagement/Public/Remove-StoreApps.ps1 index c5a3c4aa..e6312cea 100644 --- a/modules/AdminToolbox.EndpointManagement/Public/Remove-StoreApps.ps1 +++ b/modules/AdminToolbox.EndpointManagement/Public/Remove-StoreApps.ps1 @@ -1,8 +1,17 @@ <# .DESCRIPTION - Removes sponsored Windows store apps and some microsoft apps + Removes specified Windows store apps. - -Microsot Apps Removed + .PARAMETER disablesponsoredapps + Disables sponsored Windows Store apps from returning. + + .PARAMETER storeapps + An array of Windows Store apps to remove. Use wildcards (*) to match partial names. + + .EXAMPLE + $StoreApps = @( + + #Unnecessary Windows 10 AppX Apps "Microsoft.BingNews" "Microsoft.BingWeather" "Microsoft.MicrosoftSolitaireCollection" @@ -12,8 +21,26 @@ "Microsoft.WindowsCamera" "*Skype*" - .EXAMPLE - Remove-StoreApps + #Sponsored Windows 10 AppX Apps + "*EclipseManager*" + "*ActiproSoftwareLLC*" + "*AdobeSystemsIncorporated.AdobePhotoshopExpress*" + "*Duolingo-LearnLanguagesforFree*" + "*PandoraMediaInc*" + "*CandyCrush*" + "*Wunderlist*" + "*Flipboard*" + "*Twitter*" + "*Facebook*" + "*Spotify*" + "*Minecraft*" + "*Royal Revolt*" + + ) + + Remove-StoreApps -storeapps $storeapps -disablesponsoredapps -verbose + + Removes all apps in the array. .Link https://github.com/TheTaylorLee/AdminToolbox @@ -22,14 +49,15 @@ function Remove-StoreApps { [CmdletBinding(SupportsShouldProcess)] - Param ( + [Parameter(Mandatory = $false)][switch]$disablesponsoredapps, + [Parameter(Mandatory = $true)][string[]]$storeapps ) #Check for Admin Privleges Get-Elevation - $CrapApps = @( + $StoreApps = @( #Unnecessary Windows 10 AppX Apps "Microsoft.BingNews" @@ -58,27 +86,30 @@ function Remove-StoreApps { ) - foreach ($Crap in $CrapApps) { - Get-AppxPackage -Name $Crap | Remove-AppxPackage -ErrorAction SilentlyContinue - Get-AppxProvisionedPackage -Online | Where-Object DisplayName -Like $Crap | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue - Write-Output "Removing $Crap if exists." + foreach ($app in $StoreApps) { + Get-AppxPackage -Name $app | Remove-AppxPackage -ErrorAction SilentlyContinue + Get-AppxProvisionedPackage -Online | Where-Object DisplayName -Like $app | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue + Write-Output "Removing $app if exists." } - Write-Host "Adding Registry key to prevent crap apps from returning" -ForegroundColor Green - $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" - $registryOEM = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" - If (!(Test-Path $registryPath)) { - New-Item $registryPath - } - Set-ItemProperty $registryPath DisableWindowsConsumerFeatures -Value 1 + if ($disablesponsoredapps) { + + Write-Host "Adding Registry keys to prevent Sponsored Store apps from returning" -ForegroundColor Green + $registryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" + $registryOEM = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" + If (!(Test-Path $registryPath)) { + New-Item $registryPath + } + Set-ItemProperty $registryPath DisableWindowsConsumerFeatures -Value 1 - If (!(Test-Path $registryOEM)) { - New-Item $registryOEM + If (!(Test-Path $registryOEM)) { + New-Item $registryOEM + } + Set-ItemProperty $registryOEM ContentDeliveryAllowed -Value 0 + Set-ItemProperty $registryOEM OemPreInstalledAppsEnabled -Value 0 + Set-ItemProperty $registryOEM PreInstalledAppsEnabled -Value 0 + Set-ItemProperty $registryOEM PreInstalledAppsEverEnabled -Value 0 + Set-ItemProperty $registryOEM SilentInstalledAppsEnabled -Value 0 + Set-ItemProperty $registryOEM SystemPaneSuggestionsEnabled -Value 0 } - Set-ItemProperty $registryOEM ContentDeliveryAllowed -Value 0 - Set-ItemProperty $registryOEM OemPreInstalledAppsEnabled -Value 0 - Set-ItemProperty $registryOEM PreInstalledAppsEnabled -Value 0 - Set-ItemProperty $registryOEM PreInstalledAppsEverEnabled -Value 0 - Set-ItemProperty $registryOEM SilentInstalledAppsEnabled -Value 0 - Set-ItemProperty $registryOEM SystemPaneSuggestionsEnabled -Value 0 } \ No newline at end of file