1

I am having trouble with the below script. Although it says it is successful during run-time, the applications are still present within the OS. DISM log files are not helpful either.

# Remove non-corporate apps
$AppsList = "Microsoft.3DBuilder",`
            "Microsoft.Advertising.Xaml",`
            "Microsoft.Messaging",`
            "Microsoft.Microsoft3DViewer",`
            "Microsoft.Messaging",`
            "Microsoft.MicrosoftOfficeHub",`
            "Microsoft.MicrosoftSolitaireCollection",`
            "Microsoft.Office.OneNote",`
            "Microsoft.OneConnect",`
            "Microsoft.People",`
            "Microsoft.SkypeApp",`
            #"Microsoft.StorePurchaseApp",`
            "Microsoft.Wallet",`
            "Microsoft.XboxApp",`
            "Microsoft.XboxGameOverlay",`
            "Microsoft.XboxIdentityProvider",`
            "Microsoft.XboxSpeechToTextOverlay",`
            "Microsoft.ZuneMusic",`
            "Microsoft.ZuneVideo",`
            #"Microsoft.WindowsStore",`
            "microsoft.windowscommunicationsapps",`
            "Microsoft.WindowsPhone",`
            "Microsoft.Office.Sway",`
            "Microsoft.ConnectivityStore",`
            "Microsoft.CommsPhone",`
            "Microsoft.BingFinance"

ForEach ($app in $AppsList){
$variable = DISM /Online /Get-ProvisionedAppxPackages | select-string Packagename
$variable2 = $variable -replace "PackageName : ", ""
}

$variable2| % {DISM /Online /Remove-ProvisionedAppxPackage /PackageName:$_}
henrycarteruk
  • 12,708
  • 2
  • 36
  • 40
Abs
  • 21
  • 1
  • 2
  • Because you overwrite `$variable2` every time the first loop runs. You also never check the package name against the `$app` variable. Finally, I'd suggest using `Get/Remove-AppxProvisionedPackage` cmdlets instead of dism – Mathias R. Jessen Jul 25 '17 at 11:38
  • @abs i know its quite old topic but did you managed to solved it? I am also facing issue in-place upgrade. – Roxx Dec 05 '19 at 14:31

3 Answers3

1

To remove apps from current user:

ForEach ($app in $AppsList)
{
    Get-AppxPackage -Name $app | Remove-AppxPackage
}

To remove apps from new users logging onto a system use, but not remove from existing users:

ForEach ($app in $AppsList)
{
Get-AppXProvisionedPackage -Online | Where-Object { $_.DisplayName -eq  $app } | Remove-AppxProvisionedPackage -Online
}
Malcolm McCaffery
  • 2,468
  • 1
  • 22
  • 43
  • Thanks Malcolm, however as mentioned earlier, i am after a DISM solution to cater for inplace upgrades with existing users and new users. This solution does not work for inplace upgrades where existing user profiles are housed. – Abs Jul 25 '17 at 12:45
  • 1
    @Abs This is the correct answer, using `dism /Remove-ProvisionedAppxPackage` will remove the package only from the Package Store and is functionally the same `Remove-AppxProvisionedPackage`. In fact `Remove-AppxProvisionedPackage` is a `Dism` cmdlet. There isn't a `Dism.exe` equivalent switch for `Remove-AppxPackage` because the package isn't in the CBS store but is housed in the User's profile. ` – BenH Jul 25 '17 at 13:27
  • To cater for existing users you need to run Remove-AppxPackage as the user, you can do this via scheduled task at logon, or some other method of your choice. – Malcolm McCaffery Jul 25 '17 at 21:00
0

I'd use Remove-AppxProvisionedPackage instead of DISM:

# Remove non-corporate apps
$AppsList = "Microsoft.3DBuilder",`
            "Microsoft.Advertising.Xaml",`
            "Microsoft.Messaging",`
            "Microsoft.Microsoft3DViewer",`
            "Microsoft.Messaging",`
            "Microsoft.MicrosoftOfficeHub",`
            "Microsoft.MicrosoftSolitaireCollection",`
            "Microsoft.Office.OneNote",`
            "Microsoft.OneConnect",`
            "Microsoft.People",`
            "Microsoft.SkypeApp",`
            #"Microsoft.StorePurchaseApp",`
            "Microsoft.Wallet",`
            "Microsoft.XboxApp",`
            "Microsoft.XboxGameOverlay",`
            "Microsoft.XboxIdentityProvider",`
            "Microsoft.XboxSpeechToTextOverlay",`
            "Microsoft.ZuneMusic",`
            "Microsoft.ZuneVideo",`
            #"Microsoft.WindowsStore",`
            "microsoft.windowscommunicationsapps",`
            "Microsoft.WindowsPhone",`
            "Microsoft.Office.Sway",`
            "Microsoft.ConnectivityStore",`
            "Microsoft.CommsPhone",`
            "Microsoft.BingFinance"

ForEach ($app in $AppsList){
    Remove-AppxProvisionedPackage -Online -PackageName $app
}
henrycarteruk
  • 12,708
  • 2
  • 36
  • 40
  • Thanks all for your comments, the solution provided works in the scenario where Windows 10 is a new install on machines without existing profiles. However, if it is an in place upgrade with existing profiles, the remove-AppxProvisionedPackage does not apply to all the users previously logged in. DISM works for existing and new users. – Abs Jul 25 '17 at 12:13
  • You should be able to replace the `Remove-AppxProvisionedPackage` command with `DISM /Online /Remove-ProvisionedAppxPackage /PackageName:$app` – henrycarteruk Jul 25 '17 at 12:31
  • DISM /Online /Remove-ProvisionedAppxPackage /PackageName:$app does not work as i get an error 87 parameter is incorrect. DISM logs state Failed to determine whether package full name represents a bundle. – Abs Jul 25 '17 at 12:43
0

My script:

Write-Host "FiliP Bloatware Remover DISM Script 2023"
$AppsList = "Microsoft.ZuneMusic",`
            "Microsoft.ZuneVideo"
Write-Host "List to remove:"
ForEach ($app in $AppsList)
    {
        Write-Host $app
    }

ForEach ($app in $AppsList){
$PackList = DISM /Online /Get-ProvisionedAppxPackages | select-string Packagename
ForEach ($package in $PackList) 
    {
        if ($package -like "*$app*") 
            {
                $dism_app = $package -replace "PackageName : ", ""
                DISM /Online /Remove-ProvisionedAppxPackage /PackageName:$dism_app
            }
    }
}
FiliP
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 06 '23 at 23:13