none
PowerShell to hide the command prompt window while running and uninstalling the few selected AppX on Windows 10 as logon script?

    Question

  • People,

    I need some help in removing the builtin AppX or Modern Windows Store Apps as part of my Login & Startup Script.
    It is encapsulated by Batch script like below with some additional or manual PowerShell script to remove the Appx.

    @start "" /min PowerShell.exe -NoLogo -WindowStyle Hidden -NoProfile -NoInteractive -Command "Invoke-Expression -Command ((Get-Content -Path '%~f0' | Select-Object -Skip 3) -join [environment]::NewLine)" @exit /b 0 REM Remove the AppX using PowerShell command.... $t = '[DllImport("user32.dll")] public static extern bool ShowWindow(int handle, int state);' add-type -name win -member $t -namespace native [native.win]::ShowWindow(([System.Diagnostics.Process]::GetCurrentProcess() | Get-Process).MainWindowHandle, 0) Get-AppxProvisionedPackage -AllUsers "2414FC7A.Viber" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "41038Axilesoft.ACGMediaPlayer" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "46928bounde.EclipseManager" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "4DF9E0F8.Netflix" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "64885BlueEdge.OneCalendar" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "7EE7776C.LinkedInforWindows" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "828B5831.HiddenCityMysteryofShadows" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "89006A2E.AutodeskSketchBook" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "9E2F88E3.Twitter" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "A278AB0D.DisneyMagicKingdoms" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "A278AB0D.DragonManiaLegends" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "A278AB0D.MarchofEmpires" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "ActiproSoftwareLLC.562882FEEB491" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "AdobeSystemsIncorporated.AdobePhotoshopExpress" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "CAF9E577.Plex" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "D52A8D61.FarmVille2CountryEscape" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "D5EA27B7.Duolingo-LearnLanguagesforFree" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "DB6EA5DB.CyberLinkMediaSuiteEssentials" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "DolbyLaboratories.DolbyAccess" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "Drawboard.DrawboardPDF" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "E046963F.LenovoCompanion" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "Facebook.Facebook" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "Fitbit.FitbitCoach" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "GAMELOFTSA.Asphalt8Airborne" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "KeeperSecurityInc.Keeper" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "LenovoCorporation.LenovoID" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "LenovoCorporation.LenovoSettings" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "Microsoft.MicrosoftSolitaireCollection" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "Microsoft.MinecraftUWP" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "Nordcurrent.CookingFever" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "PandoraMediaInc.29680B314EFC2" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "SpotifyAB.SpotifyMusic" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "WinZipComputing.WinZipUniversal" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "XINGAG.XING" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "flaregamesGmbH.RoyalRevolt2" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "king.com.BubbleWitch3Saga" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "king.com.CandyCrushSaga" | Remove-AppxProvisionedPackage Get-AppxProvisionedPackage -AllUsers "king.com.CandyCrushSodaSaga" | Remove-AppxProvisionedPackage exit

    The problem with the script below that I need some assistance is:

    1. The script always popping up Command Prompt window
    2. The script is always executed even though the application has already been uninstalled, so there is no way to skip it if the apps is not even listed.

    Any kind of help would be greatly appreciated.

    Thanks.


    /* Server Support Specialist */

    Thursday, December 6, 2018 1:14 PM

Answers

  • The MDT forum is your best bet for help with modifying deployed images and images you would deploy.

    If you purchased consumer grade machines there will be issue with the delivered recovery software and with the deployed apps.  Contact the vendor if these issues arise.

    In a corporate environment it is a good practice to never purchase consumer grade (or retail) systems.  The enterprise packages can be ordered "raw" and you can deploy your own custom image which will eliminate all of this.


    \_(ツ)_/

    Friday, December 7, 2018 2:27 AM
    Moderator

All replies

  • A standard user cannot remove a provisioning package.

    These commands are used after an installation to remove the product from the system.  It is not a user command.

    The parameters you are using are also wrong.

    help  Get-AppxProvisionedPackage -Full


    \_(ツ)_/

    Thursday, December 6, 2018 1:47 PM
    Moderator
  • A standard user cannot remove a provisioning package.

    These commands are used after an installation to remove the product from the system.  It is not a user command.

    The parameters you are using are also wrong.

    help  Get-AppxProvisionedPackage -Full


    \_(ツ)_/

    OK, here's the updated script.

    $t = '[DllImport("user32.dll")] public static extern bool ShowWindow(int handle, int state);'
    add-type -name win -member $t -namespace native
    [native.win]::ShowWindow(([System.Diagnostics.Process]::GetCurrentProcess() | Get-Process).MainWindowHandle, 0)
    
    Get-AppxPackage -AllUsers "2414FC7A.Viber" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "41038Axilesoft.ACGMediaPlayer" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "46928bounde.EclipseManager" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "4DF9E0F8.Netflix" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "64885BlueEdge.OneCalendar" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "7EE7776C.LinkedInforWindows" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "828B5831.HiddenCityMysteryofShadows" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "89006A2E.AutodeskSketchBook" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "9E2F88E3.Twitter" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "A278AB0D.DisneyMagicKingdoms" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "A278AB0D.DragonManiaLegends" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "A278AB0D.MarchofEmpires" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "ActiproSoftwareLLC.562882FEEB491" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "AdobeSystemsIncorporated.AdobePhotoshopExpress" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "CAF9E577.Plex" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "D52A8D61.FarmVille2CountryEscape" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "D5EA27B7.Duolingo-LearnLanguagesforFree" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "DB6EA5DB.CyberLinkMediaSuiteEssentials" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "DolbyLaboratories.DolbyAccess" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "Drawboard.DrawboardPDF" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "E046963F.LenovoCompanion" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "Facebook.Facebook" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "Fitbit.FitbitCoach" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "GAMELOFTSA.Asphalt8Airborne" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "KeeperSecurityInc.Keeper" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "LenovoCorporation.LenovoID" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "LenovoCorporation.LenovoSettings" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "Microsoft.MicrosoftSolitaireCollection" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "Microsoft.MinecraftUWP" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "Nordcurrent.CookingFever" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "PandoraMediaInc.29680B314EFC2" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "SpotifyAB.SpotifyMusic" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "WinZipComputing.WinZipUniversal" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "XINGAG.XING" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "flaregamesGmbH.RoyalRevolt2" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "king.com.BubbleWitch3Saga" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "king.com.CandyCrushSaga" | Remove-AppxPackage
    Get-AppxPackage -AllUsers "king.com.CandyCrushSodaSaga" | Remove-AppxPackage
    
    exit


    My goal here is to be able to remove all AppX for the users as part of the Logon script, but do not display the command prompt window.

    Basically, I just wanted to enforce only the below Appx that can be installed:

    Microsoft.MicrosoftStickyNotes
    Microsoft.StorePurchaseApp    
    Microsoft.windowscalculator   
    Microsoft.WindowsStore

    using the script:

    Get-AppxProvisionedPackage -Online | Where-Object {$_.PackageName –like '*store*' -or $_.PackageName –like '*Calc*' -or $_.PackageName –like '*Notes*'} 


    /* Server Support Specialist */


    Friday, December 7, 2018 1:52 AM
  • Only an elevates admin can use the "-AllUsers" parameter.

    What you are doing can be done more easily using Group Policy.  Talk to your AD and network Admins to have them set GP to disallow these apps.


    \_(ツ)_/

    Friday, December 7, 2018 2:00 AM
    Moderator
  • Only an elevates admin can use the "-AllUsers" parameter.

    What you are doing can be done more easily using Group Policy.  Talk to your AD and network Admins to have them set GP to disallow these apps.


    \_(ツ)_/

    Yes, I have already think about that.

    I need the Group Policy steps to implement but still allowing:
    Calculator and Notes to be executed with no issue.

    Computer Configuration\Administrative Templates\Windows Components\Cloud Content
    However, This setting only applies to Enterprise and Education SKUs.


    /* Server Support Specialist */

    Friday, December 7, 2018 2:02 AM
  • Just remove all packages from the system once as an admin.  No need to do this on every logon.

    The original code can remove the provisioning package permanently.  The link I posted explains this and shows how to do it.  It notes that this isusually done once either after the image is deployed or directly on the deployment issue.

    Post questions in the MDT forum and they will help you understand how to prepare images.


    \_(ツ)_/

    Friday, December 7, 2018 2:05 AM
    Moderator
  • Just remove all packages from the system once as an admin.  No need to do this on every logon.

    The original code can remove the provisioning package permanently.  The link I posted explains this and shows how to do it.  It notes that this isusually done once either after the image is deployed or directly on the deployment issue.

    Post questions in the MDT forum and they will help you understand how to prepare images.


    \_(ツ)_/

    Hi JRV,

    Unfortunately, the Windows 10 Workstations has been deployed already and it has not been removed since the beginning by HP and Dell:

    Windows 10 Professional is currently used by the physical workstations as they come up builtin with HP, Dell and Lenovo workstations.

    Windows 10 Enterprise is currently used for the VDI client and remote site users as Virtual Machine.

    Which link that you suggested?


    /* Server Support Specialist */

    Friday, December 7, 2018 2:08 AM
  • The MDT forum is your best bet for help with modifying deployed images and images you would deploy.

    If you purchased consumer grade machines there will be issue with the delivered recovery software and with the deployed apps.  Contact the vendor if these issues arise.

    In a corporate environment it is a good practice to never purchase consumer grade (or retail) systems.  The enterprise packages can be ordered "raw" and you can deploy your own custom image which will eliminate all of this.


    \_(ツ)_/

    Friday, December 7, 2018 2:27 AM
    Moderator
  • I believe you have to work with "Get-AppxProvisionedPackage -online" and "Remove-AppxProvisionedPackage –online", but you only have to run it once as admin.

    Friday, December 7, 2018 8:14 PM