Syntax for Post 1511 to 1607 OS Upgrade Cleanup Script?


  • We are going to upgrade Windows 10 laptops to the latest version remotely by having the systems install the updates via Microsoft Update while the users are in their own homes.

    Since we will not be using a customized image with apps already removed, after the upgrade completes, we need PowerShell Commands to run to remove the built-in apps that get installed as part of the OS upgrade.

    This page: says this can be accomplished by creating a SetupConfig.ini file and having that file point to a batch file with commands (PowerShell or other).

    I would like to include PowerShell commands uninstall all the unwanted apps after the OS upgrade completes before the user can even log into the laptop.

    The link above says the SetupConfig.ini contains this:


    The setupconfig.ini file is copied to %systemdrive%\Users\Default\AppData\Local\Microsoft\Windows\WSUS\SetupConfig.ini

    We could use Group Policy to prestage the setup.ini file and cleanup.cmd files to the local disks before the laptops get the Windows Update upgrade approved.

    What syntax is used in the Cleanup.cmd file to run the PowerShell commands to uninstall the apps, bypass execution policy and run elevated (if required). Not sure if it needs to be explicitly be set to run elevated if this part of an OS upgrade that I assume has system level access automatically.

    What commands would go into the  cleanup.cmd file before copying to the local disks before you add the lines specifying the apps you want to remove such as: 

    Remove-AppxProvisionedPackage -Online -PackageName Microsoft.XboxApp_2016.728.453.0_neutral_~_8wekyb3d8bbwe etc.?

    Friday, March 3, 2017 5:55 AM


  • Hi MyGposts,

    For new users, the Syntax looks like this:
    "Remove-AppxProvisionedPackage  -Online  -PackageName packagename"
    For existing users, the Syntax looks like this:
    "Get-AppxPackage packagename | Remove-AppxPackage"

    We could run "get-appxapckage" to get a list of all the built-in metro app packages. Please note some packages couldn't be removed such as "Microsoft Edge".

    Best regards

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact

    • Marked as answer by MyGposts Thursday, March 9, 2017 4:59 AM
    Monday, March 6, 2017 6:34 AM