Jump to content

Automate Limitations? App Remover

Recommended Posts

$AppList = @(



foreach ($app in $AppList) {
	$GetApp = Get-AppxPackage -Name $app -AllUsers
    if ($GetApp -ne $null) {
	Write-Host "Trying to remove $app"
    Get-AppxPackage -Name $app -AllUsers | Remove-AppxPackage
    Get-AppXProvisionedPackage -Online | where DisplayName -EQ $app | Remove-AppxProvisionedPackage -Online
	start-sleep 20
	Write-Host "$app not found"
	if ($GetApp -eq $null) {
	Write-Host "$app removed sucessfully." 
	Write-Host "$app removal failed"

Above is a very simple script I wrote that lets you list apps you don't want (in this case Farm Hero and Candy Crush) that come preinstalled with Windows.

Thing is, it works fine in PowerShell as Admin but it will not work in Automate or backstage. I've got several other scripts running correctly, but something about this one fails. I even tried using Super User execution permissions and still nothing. I'm planning on doing a work around using a temp-Task Scheduler  thing, but I want this to work 'cause I cant get the logs that way.

Any suggestions?


Share this post

Link to post
Share on other sites

Try taking a look at how to run a script on a logged in users console.

You will need to launch the above script every time a new user logs into a PC as windows will add applications those newly logged in users.

Share this post

Link to post
Share on other sites

We had old Windows 10 installs, some that were Home > Pro upgrades from a customer-purchased machine, some were Intel compute sticks, but in any case there was anywhere from 700MB to 30GB of junk files and appx package updates/revisions. I built out a remote monitor to automate the cleanup and disable of the consumer features and packages.

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass $ErrorActionPreference = 'SilentlyContinue'; $AppXApps = @('king*','nordcurrent*','Microsoft.whiteboard*','*EclipseManager*','*ActiproSoftwareLLC*','*AdobeSystemsIncorporated.AdobePhotoshopExpress*','*Duolingo-LearnLanguagesforFree*','*PandoraMediaInc*','*Wunderlist*','*Flipboard*','*.PicsArt-PhotoStudio','*.PolarrPhotoEditorAcademicEdition','*.Wunderlist','*.LinkedInforWindows','*.AutodeskSketchBook','*.DisneyMagicKingdoms','*.MarchofEmpires','ActiproSoftwareLLC.562882FEEB491','*.FarmVille2CountryEscape','*.Duolingo-LearnLanguagesforFree','Drawboard.DrawboardPDF','Fitbit.FitbitCoach','GAMELOFTSA.*','KeeperSecurityInc.Keeper','Playtika.*','ThumbmunkeysLtd.PhototasticCollage','WinZipComputing.WinZipUniversal','XINGAG.XING','flaregamesGmbH.*');$sizebefore=0;foreach($app in $AppXApps){$path = $('c:\program files\windowsapps\' + $App); if(Test-Path $path){$checkpath=Get-ChildItem -Path $path -Recurse | Measure-Object -Sum Length; if($checkpath){$sizebefore+=$checkpath.Sum}}}$beforemb=[math]::Round(($sizebefore/1MB),0);Write-Output $beforemb

The monitor outputs a MB value, set with 0 as the desired result. Failure runs a script that executes this powershell script to clean things up and set the necessary registry keys to disable the consumer features at the system level to prevent install for new users.

$AppXApps = @(

foreach ($App in $AppXApps) {
    Write-Verbose -Message ('Removing Package {0}' -f $App)
    Get-AppxPackage -Name $App -AllUsers | Remove-AppxPackage -AllUsers -ErrorAction SilentlyContinue
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like $App | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue
    Remove-Item $('c:\program files\windowsapps\' + $App) -Recurse -Force -Verbose -ErrorAction SilentlyContinue

if(!Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" -ErrorAction SilentlyContinue){

    force-mkdir "HKLM:\SOFTWARE\Policies\Microsoft\WindowsStore"

Set-ItemProperty "HKLM:\SOFTWARE\Policies\Microsoft\WindowsStore" "AutoDownload" 2 -Force

# Prevents "Suggested Applications" returning
if(!Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" -ErrorAction SilentlyContinue){
    force-mkdir "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent"


Set-ItemProperty "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" "DisableWindowsConsumerFeatures" 1 -Force


Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...