none
Removing apps during a task sequence RRS feed

  • Question

  • Hi,

    I was trying to remove  apps in build and deploy task sequence  , But it was ending in an error something went wrong  . 

    After retry it continued and build the image  . 

    After I disable remove-apps sequence , it did not show the error "something went wrong " 

    https://blogs.technet.microsoft.com/mniehaus/2015/11/11/removing-windows-10-in-box-apps-during-a-task-sequence/

    Am I missing something 

    adk is 1703 and windows 1703  

    As per the document we can do it in offline and online mode 

    How can i do in offline and online mode  

    Thanks

    Wednesday, October 4, 2017 1:57 PM

Answers

  • Youl are actually running into multiple issues:

    1. Windows Store is pulling down consumer apps during your TS. These apps are installed for the signed-on user, not provisioning on the machine.  So the script ignores them, as it’s only looking at provisioned apps. So how do you get rid of these?  The simplest way is to keep them from installing in the first place. Add following to your unattend.xml (Change Order value to match your XML):

    <RunSynchronousCommand wcm:action="add">
        <Description>disable consumer features</Description>
        <Order>5</Order>
        <Path>reg add HKLM\Software\Policies\Microsoft\Windows\CloudContent /v DisableWindowsConsumerFeatures /t REG_DWORD /d 1 /f</Path>
    </RunSynchronousCommand>

    2. Windows Store updates apps during your TS. If an all-user package that's provisioned into the image was manually deprovisioned from the image but not removed for a particular user, the provider will encounter an error while cleaning out this package during sysprep. The provider will also fail if an all-user package that's provisioned into the image was updated by one of the users on this reference computer.

    Add this to your unattend.xml to disable Store auto update (Change Order value to match your XML):

    <RunSynchronousCommand wcm:action="add">
    			<Description>disable consumer features</Description>
    			<Order>9</Order>
    			<Path>reg add HKLM\SOFTWARE\Policies\Microsoft\WindowsStore /v AutoDownload /t REG_DWORD /d 2 /f</Path>
    		</RunSynchronousCommand>

    3. Disable automatic Windows Update and let MDT handle that by setting ProtectYourPC value to 3:

          <OOBE>
            <HideEULAPage>true</HideEULAPage>
            <NetworkLocation>Work</NetworkLocation>
            <ProtectYourPC>3</ProtectYourPC>
            <HideLocalAccountScreen>true</HideLocalAccountScreen>
            <HideOnlineAccountScreens>true</HideOnlineAccountScreens>
            <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
          </OOBE>


    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".


    • Edited by Anton Romanyuk Monday, October 9, 2017 7:29 AM clarification
    • Proposed as answer by Anton Romanyuk Monday, October 9, 2017 7:30 AM
    • Marked as answer by supportsib Monday, October 9, 2017 2:55 PM
    Monday, October 9, 2017 7:29 AM

All replies

  • I myself never had any issues with Michael's script. Are you also including a RemoveApps.xml? By default you can remove some pretty important stuff like the Windows Store and its dependecies, which is inwise to say the least.

    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Wednesday, October 4, 2017 3:56 PM
  • Hi,

    The script should be included in the reference image task sequence  ?

    or  in the deployment task sequence of final image ?

    Thanks

    Wednesday, October 4, 2017 4:30 PM
  • I'd do this during reference image creation - best place to do it.

    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Wednesday, October 4, 2017 4:56 PM
  • Hi

    Thanks for the reply . If in case it did not work 

    Can I do it offline  on the image ( reference image ) 

    https://blogs.technet.microsoft.com/mniehaus/2016/08/23/windows-10-1607-keeping-apps-from-coming-back-when-deploying-the-feature-update/

    Thanks

    Wednesday, October 4, 2017 9:30 PM
  • I have seen cases where you can use DISM to mount the WIM file and remove packages from it, Microsoft actually encourages that method https://community.spiceworks.com/topic/1548590-dism-to-remove-win10-appx-apps-from-wim  

    I cant seem to find the original microsoft technet article that showed this, but its out there.

    I personally use https://github.com/W4RH4WK/Debloat-Windows-10 as steps in my task sequence (edited to make changes for stuff i want to remove/keep) and keep my options open in case I want to factory reset a workstation for disposal.

    Wednesday, October 4, 2017 10:31 PM
  • Hi

    Thanks for the reply . If in case it did not work 

    Can I do it offline  on the image ( reference image ) 

    https://blogs.technet.microsoft.com/mniehaus/2016/08/23/windows-10-1607-keeping-apps-from-coming-back-when-deploying-the-feature-update/

    Thanks

    You could. I linked a modified app removal script in the comments section of Michael's article: https://www.dropbox.com/s/xeahun3fjf0yhxe/MDT-WIMServicing.ps1?dl=0

    However, I am curios, why is Michael's script not working for you in offline mode? Depending on ADK / MDT version you are using, you may need to apply a workaround: https://blogs.technet.microsoft.com/mniehaus/2015/12/31/updated-remove-apps-script-and-a-workaround/

    You also need to include extra features in your boot image like PowerShell, etc, which Michael outlined in his original post.


    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".


    Thursday, October 5, 2017 6:37 AM
  • Hi,

    Can you share the task sequence  information regarding debloat script 

    Thanks

    Friday, October 6, 2017 10:26 AM
  • I am doing nothing different than what Michael is describing in his original blog post: https://blogs.technet.microsoft.com/mniehaus/2015/11/11/removing-windows-10-in-box-apps-during-a-task-sequence/

    You may need to apply this workaround depending on your ADK version: https://blogs.technet.microsoft.com/mniehaus/2015/12/31/updated-remove-apps-script-and-a-workaround/


    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    • Proposed as answer by Anton Romanyuk Monday, October 9, 2017 7:30 AM
    Friday, October 6, 2017 10:58 AM
  • Hi,
    I am running the script  as offline in task sequence .
    The error I am getting is below 

    "Failed to run the last action Set-Executionpolicy Bypass "

    Thanks
    Sunday, October 8, 2017 7:55 AM
  • Did you include all necessary components in your WinPE image?

    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Sunday, October 8, 2017 8:02 AM
  • Yes

    Powershell 

    dotnet 

    Sunday, October 8, 2017 9:05 AM
  • Also DISM cmdlets, etc, as outlined in the linked post? Regardless, what is your full command line you are trying to run?

    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Sunday, October 8, 2017 9:20 AM
  • Hi,

    yes Dism , dotnet , powersehll storage cmdlets 

    Powershell.exe -command “Set-ExecutionPolicy Bypass” 

    Thanks

    Sunday, October 8, 2017 10:15 AM
  • Looks solid. Verify that your command does not contain any illegal characters. Here is a copy & pasted cmdline from my task sequence:

    powershell.exe -command "Set-ExecutionPolicy Bypass"

    If it still does not work for, please post <g class="gr_ gr_246 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins replaceWithoutSep" data-gr-id="246" id="246">full</g> error message you are receiving when your TS tries to run the command.


    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Sunday, October 8, 2017 10:56 AM
  • Hi,

    I have tried "MDT-WIMServicing"  with windows 10  iso  image (sources/install.wim) . It works perfect .

    But When I am trying with my reference image I am getting the following error 

    MDT-WIMServicing.ps1 - Removing Apps
    Remove-AppxProvisionedPackage : The system cannot find the file specified.
    At C:\foo\MDT-WIMServicing.ps1:113 char:14
    + ...        $a = Remove-AppxProvisionedPackage -Path $mount_full -PackageN ...
    +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Remove-AppxProvisionedPackage], COMException
        + FullyQualifiedErrorId : Microsoft.Dism.Commands.RemoveAppxProvisionedPackageCommand

    Thanks

    Sunday, October 8, 2017 5:22 PM
  • Check the parameter for mount path and make sure you run the script as administrator. Does the script create RemoveApps.xml in the same folder?

    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Sunday, October 8, 2017 7:46 PM
  • Hi,

    Mounting is working fine ,Script did not create RemoveApps.xml

    Thanks

    Sunday, October 8, 2017 8:55 PM
  • Hi,

    Sorry it created the removeapps.xml

    Thanks

    Monday, October 9, 2017 5:18 AM
  • Hi,

    Looks solid. Verify that your command does not contain any illegal characters. Here is a copy & pasted cmdline from my task sequence:

    powershell.exe -command "Set-ExecutionPolicy Bypass"

    If it still does not work for, please post <g class="gr_ gr_246 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins replaceWithoutSep" data-gr-id="246" id="246">full</g> error message you are receiving when your TS tries to run the command.

    Finally  it run , But now sysprep failed 

    2017-10-08 05:17:57, Info                  SYSPRP ========================================================
    2017-10-08 05:17:57, Info                  SYSPRP ===          Beginning of a new sysprep run          ===
    2017-10-08 05:17:57, Info                  SYSPRP ========================================================
    2017-10-08 05:17:57, Info       [0x0f004d] SYSPRP The time is now 2017-10-08 05:17:57
    2017-10-08 05:17:57, Info       [0x0f004e] SYSPRP Initialized SysPrep log at C:\windows\system32\sysprep\Panther
    2017-10-08 05:17:57, Info       [0x0f0054] SYSPRP ValidatePrivileges:User has required privileges to sysprep machine
    2017-10-08 05:17:57, Info       [0x0f007e] SYSPRP FCreateTagFile:Tag file C:\windows\system32\sysprep\Sysprep_succeeded.tag does not already exist, no need to delete anything
    2017-10-08 05:17:57, Info       [0x0f005f] SYSPRP ParseCommands:Found supported command line option 'QUIET'
    2017-10-08 05:17:57, Info       [0x0f005f] SYSPRP ParseCommands:Found supported command line option 'GENERALIZE'
    2017-10-08 05:17:57, Info       [0x0f005f] SYSPRP ParseCommands:Found supported command line option 'OOBE'
    2017-10-08 05:17:57, Info       [0x0f005f] SYSPRP ParseCommands:Found supported command line option 'QUIT'
    2017-10-08 05:17:57, Info       [0x0f005f] SYSPRP ParseCommands:Found supported command line option 'UNATTEND'
    2017-10-08 05:17:57, Info       [0x0f00d7] SYSPRP WinMain:Pre-validing 'cleanup' internal providers.
    2017-10-08 05:17:57, Info                  SYSPRP RunExternalDlls:Running platform actions specified in action file for phase 3
    2017-10-08 05:17:58, Info       [0x0f00ba] SYSPRP SysprepSession::CreateSession: Successfully created instance with mount path C:, action file C:\Windows\System32\Sysprep\ActionFiles\Cleanup.xml, and mode <null>
    2017-10-08 05:17:58, Info                  SYSPRP SysprepSession::Validate: Beginning action execution from C:\Windows\System32\Sysprep\ActionFiles\Cleanup.xml
    2017-10-08 05:17:58, Info                  SYSPRP ActionPlatform::GetStringValue: Getting REG_SZ value SysprepMode under key HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Setup\Sysprep
    2017-10-08 05:17:58, Info                  SYSPRP ActionPlatform::GetValue: Getting value SysprepMode under key HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Setup\Sysprep
    2017-10-08 05:17:58, Warning               SYSPRP ActionPlatform::GetValue: Error from RegQueryValueEx on value SysprepMode under key HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Setup\Sysprep; dwRet = 0x2
    2017-10-08 05:17:58, Info                  SYSPRP SysprepSession::CreateXPathForSelection: Sysprep mode in registry is <null>
    2017-10-08 05:17:58, Info                  SYSPRP ActionPlatform::GetStringValue: Getting REG_SZ value PROCESSOR_ARCHITECTURE under key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
    2017-10-08 05:17:58, Info                  SYSPRP ActionPlatform::GetValue: Getting value PROCESSOR_ARCHITECTURE under key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
    2017-10-08 05:17:58, Info                  SYSPRP SysprepSession::CreateXPathForSelection: Processor architecture in registry is AMD64
    2017-10-08 05:17:58, Info       [0x0f0080] SYSPRP ActionPlatform::LaunchModule: Found 'Sysprep_Clean_Validate_Opk' in C:\Windows\System32\spopk.dll; executing it
    2017-10-08 05:18:31, Error      [0x0f00b0] SYSPRP spopk.dll:: Failed to query pending CBS operations; hr = 0x8007041d
    2017-10-08 05:18:31, Error      [0x0f0082] SYSPRP ActionPlatform::LaunchModule: Failure occurred while executing 'Sysprep_Clean_Validate_Opk' from C:\Windows\System32\spopk.dll; dwRet = 0x41d
    2017-10-08 05:18:31, Error                 SYSPRP SysprepSession::Validate: Error in validating actions from C:\Windows\System32\Sysprep\ActionFiles\Cleanup.xml; dwRet = 0x41d
    2017-10-08 05:18:31, Error                 SYSPRP RunPlatformActions:Failed while validating SysprepSession actions; dwRet = 0x41d
    2017-10-08 05:18:31, Error      [0x0f0070] SYSPRP RunExternalDlls:An error occurred while running registry sysprep DLLs, halting sysprep execution. dwRet = 0x41d
    2017-10-08 05:18:31, Error      [0x0f00d8] SYSPRP WinMain:Hit failure while pre-validate sysprep cleanup internal providers; hr = 0x8007041d
    2017-10-08 05:18:31, Info       [0x0f0052] SYSPRP Shutting down SysPrep log
    2017-10-08 05:18:31, Info       [0x0f004d] SYSPRP The time is now 2017-10-08 05:18:31

    And once i logged in to the image mine craft like apps returned back 

    Please help


    • Edited by supportsib Monday, October 9, 2017 6:57 AM
    Monday, October 9, 2017 6:55 AM
  • Youl are actually running into multiple issues:

    1. Windows Store is pulling down consumer apps during your TS. These apps are installed for the signed-on user, not provisioning on the machine.  So the script ignores them, as it’s only looking at provisioned apps. So how do you get rid of these?  The simplest way is to keep them from installing in the first place. Add following to your unattend.xml (Change Order value to match your XML):

    <RunSynchronousCommand wcm:action="add">
        <Description>disable consumer features</Description>
        <Order>5</Order>
        <Path>reg add HKLM\Software\Policies\Microsoft\Windows\CloudContent /v DisableWindowsConsumerFeatures /t REG_DWORD /d 1 /f</Path>
    </RunSynchronousCommand>

    2. Windows Store updates apps during your TS. If an all-user package that's provisioned into the image was manually deprovisioned from the image but not removed for a particular user, the provider will encounter an error while cleaning out this package during sysprep. The provider will also fail if an all-user package that's provisioned into the image was updated by one of the users on this reference computer.

    Add this to your unattend.xml to disable Store auto update (Change Order value to match your XML):

    <RunSynchronousCommand wcm:action="add">
    			<Description>disable consumer features</Description>
    			<Order>9</Order>
    			<Path>reg add HKLM\SOFTWARE\Policies\Microsoft\WindowsStore /v AutoDownload /t REG_DWORD /d 2 /f</Path>
    		</RunSynchronousCommand>

    3. Disable automatic Windows Update and let MDT handle that by setting ProtectYourPC value to 3:

          <OOBE>
            <HideEULAPage>true</HideEULAPage>
            <NetworkLocation>Work</NetworkLocation>
            <ProtectYourPC>3</ProtectYourPC>
            <HideLocalAccountScreen>true</HideLocalAccountScreen>
            <HideOnlineAccountScreens>true</HideOnlineAccountScreens>
            <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
          </OOBE>


    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".


    • Edited by Anton Romanyuk Monday, October 9, 2017 7:29 AM clarification
    • Proposed as answer by Anton Romanyuk Monday, October 9, 2017 7:30 AM
    • Marked as answer by supportsib Monday, October 9, 2017 2:55 PM
    Monday, October 9, 2017 7:29 AM

  • Hi,

    DisableWindowsConsumerFeatures already  in my unattended.xml 

    <RunSynchronousCommand wcm:action="add">
    <Description>disable consumer features</Description>
    <Order>5</Order>
    <Path>reg add HKLM\Software\Policies\Microsoft\Windows\CloudContent /v DisableWindowsConsumerFeatures /t REG_DWORD /d 1 /f</Path>
    </RunSynchronousCommand>


    after logging to the pc I can see the KLM\Software\Policies\Microsoft\Windows\CloudContent\ DisableWindowsConsumerFeatures  value is 1 

    and the below also already there 
                <OOBE>
                    <HideEULAPage>true</HideEULAPage>
                    <NetworkLocation>Work</NetworkLocation>
                    <ProtectYourPC>3</ProtectYourPC>
                    <HideLocalAccountScreen>true</HideLocalAccountScreen>
                    <HideOnlineAccountScreens>true</HideOnlineAccountScreens>
                    <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
                </OOBE>

    Now the sysprep worked without doing any change .:) . I dont'know how 

    Anyway I will add the below 

    <Description>disable store autodownload</Description>
    <Order>6</Order>
    <Path>reg add HKLM\SOFTWARE\Policies\Microsoft\WindowsStore /v AutoDownload /t REG_DWORD /d 2 /f</Path>
    </RunSynchronousCommand>

    Thanks
    Monday, October 9, 2017 10:16 AM
  • Hi,

    Even after adding  the below registry value i can still see candy crush and other apps 

    <RunSynchronousCommand wcm:action="add">
    			<Description>disable consumer features</Description>
    			<Order>9</Order>
    			<Path>reg add HKLM\SOFTWARE\Policies\Microsoft\WindowsStore /v AutoDownload /t REG_DWORD /d 2 /f</Path>
    		</RunSynchronousCommand>

    Thanks

    Monday, October 9, 2017 10:30 AM
  • Are you seeing shortcuts or are the apps actually installed. Regardless, it should not be happening if you are disabling Cloud Experience.

    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Monday, October 9, 2017 10:38 AM
  • Hi,

    In administrator profile there is no apps only shortcuts . 

    For testing purpose i created a local account ,Found candy crush paint3d, sketchbook and all in the local test profile .


    Thanks

    Monday, October 9, 2017 11:47 AM
  • Hi,

    Windows professional , it may not work ? 

    Thanks

    Monday, October 9, 2017 2:20 PM
  • It would appear that starting with Windows 10 1607 Microsoft limits possibilities to control Cloud Content on Professional editions of Windows 10:


    Cheers,
    Anton

    Vacuum Breather Blog | Wing Commander Saga | Twitter

    Note: Posts are provided "AS IS" without warranty of any kind. If posts are helpful please don't forget to rate them as "Helpful" or as "Answer".

    Monday, October 9, 2017 2:33 PM