This PowerShell script should uninstall all Windows 11/10 bloatware, except $WhitelistedApps, When I run the script on a VM, it tries to uninstall all bloatware, even $WhitelistedApps!
This is a waste of time, the script will try to uninstall WhitelistedApps, but they are already NonRemovable, so I want to exclude them.
Please, Tell me: What's wrong with the code?, and how can it be corrected?
I suspicious of the way i used -NotLike, or maybe the way of quotation marks "" that have package names.
$WhitelistedApps = @(
"1527c705-839a-4832-9118-54d4Bd6a0c89"
"E2A4F912-2574-4A75-9BB0-0D023378592B"
"F46D4000-FD22-4DB4-AC8E-4E1DDDE828FE"
"Microsoft.AAD.BrokerPlugin"
"Microsoft.AccountsControl"
"Microsoft.AsyncTextService"
"Microsoft.BioEnrollment"
"Microsoft.CredDialogHost"
"Microsoft.ECApp"
"Microsoft.LockApp"
"Microsoft.MicrosoftEdge"
"Microsoft.MicrosoftEdgeDevToolsClient"
"Microsoft.PPIProjection"
"Microsoft.Win32WebViewHost"
"Microsoft.Windows.Apprep.ChxApp"
"Microsoft.Windows.AssignedAccessLockApp"
"Microsoft.Windows.CallingShellApp"
"Microsoft.Windows.CapturePicker"
"Microsoft.Windows.CloudExperienceHost"
"Microsoft.Windows.ContentDeliveryManager"
"Microsoft.Windows.Cortana"
"Microsoft.Windows.NarratorQuickStart"
"Microsoft.Windows.OOBENetworkCaptivePortal"
"Microsoft.Windows.OOBENetworkConnectionFlow"
"Microsoft.Windows.ParentalControls"
"Microsoft.Windows.PeopleExperienceHost"
"Microsoft.Windows.PinningConfirmationDialog"
"Microsoft.Windows.Search"
"Microsoft.Windows.SecHealthUI"
"Microsoft.Windows.SecondaryTileExperience"
"Microsoft.Windows.SecureAssessmentBrowser"
"Microsoft.Windows.ShellExperienceHost"
"Microsoft.Windows.StartMenuExperienceHost"
"Microsoft.Windows.XGpuEjectDialog"
"Microsoft.XboxGameCallableUI"
"MicrosoftWindows.Client.CBS"
"MicrosoftWindows.UndockedDevKit"
"NcsiUwpApp"
"Windows.CBSPreview"
"Windows.ContactSupport"
"Windows.MiracastView"
"Windows.PrintDialog"
"c5e2524a-ea46-4f67-841f-6a9465d9d515"
"windows.immersivecontrolpanel"
)
foreach ($App in $WhitelistedApps) {
Get-AppxPackage | Where-Object {$_.Name -NotLike $App} | Remove-AppxPackage
}
}