sysprep /generalize fails due to appx package Microsoft.SecHealthUI, but it cannot be removed (24H2).

Keith Blackwell 16 Reputation points
2025-05-12T16:01:19.7233333+00:00

I'm nearing final steps in updating a customized (OEM) production Windows 11 Pro image (for a Lenovo V14g4), upgrading from 22H2 to 24H2, and have had to work through many, many issues (more than ever before for past versions of Windows). But I've gotten through them all, up to this one. I'm in Audit mode with default Administrator user, trying to generalize (after which I plan to update the USMT.ppkg with scanstate and then switch to WinPE to make a few last-second edits on the offline image before capturing it with DISM). I've already done this earlier, made a few updates and appended to the image (up to index 4 now), so I was certainly able to generalize then; but recently I had to go back into Audit mode to install newer versions of device drivers (National Instruments). Almost there! But this problem has me stuck.

Normally, when sysprep /generalize fails for an app package, complaining that it "was installed for a user, but not provisioned for all users", all you have to do is Remove-AppxPackage (in powershell) for that package -- several iterations of that, and then you're good to go. I even have a script to speed up that process. But this is a package that cannot be removed, period. So it seems that maybe the left hand doesn't know what the right hand is doing, or something. I mean, what in the world is sysprep even trying to do here, and why? It says "Failed to remove apps for the current user", but, uh, generally speaking, it doesn't remove any apps, anyway, does it?

I've sought answers online, and found nothing for this specific issue. Here is a console summary:

C:\Windows\System32\Sysprep>sysprep /oobe /generalize /quit /unattend:E:\AnswerFiles\unattendGeneralizeOnly.xml 
C:\Windows\System32\Sysprep>type Panther\setuperr.log 
2025-05-09 14:21:49, Error                 SYSPRP Package Microsoft.SecHealthUI_1000.27777.1008.0_x64__8wekyb3d8bbwe was installed for a user, but not provisioned for all users. This package will not function properly in the sysprep image.
2025-05-09 14:21:49, Error                 SYSPRP Failed to remove apps for the current user: 0x80073cf2.                
2025-05-09 14:21:49, Error                 SYSPRP Exit code of RemoveAllApps thread was 0x3cf2.
2025-05-09 14:21:49, Error                 SYSPRP ActionPlatform::LaunchModule: Failure occurred while executing 'SysprepGeneralizeValidate' from C:\Windows\System32\AppxSysprep.dll; dwRet = 0x3cf2 
2025-05-09 14:21:49, Error                 SYSPRP SysprepSession::Validate: Error in validating actions from C:\Windows\System32\Sysprep\ActionFiles\Generalize.xml; dwRet = 0x3cf2 
2025-05-09 14:21:49, Error                 SYSPRP RunPlatformActions:Failed while validating Sysprep session actions; dwRet = 0x3cf2 
2025-05-09 14:21:49, Error      [0x0f0070] SYSPRP RunDlls:An error occurred while running registry sysprep DLLs, halting sysprep execution. dwRet = 0x3cf2 
2025-05-09 14:21:49, Error      [0x0f00d8] SYSPRP WinMain:Hit failure while pre-validate sysprep generalize internal providers; hr = 0x80073cf2   
C:\Windows\System32\Sysprep>powershell 
Windows PowerShell 
Copyright (C) Microsoft Corporation. All rights reserved. 
Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows 
PS C:\Windows\System32\Sysprep> Remove-AppxPackage -Package 'Microsoft.SecHealthUI_1000.27777.1008.0_x64__8wekyb3d8bbwe' 
Remove-AppxPackage : Deployment failed with HRESULT: 0x80073CFA, Removal failed. Please contact your software vendor. 
(Exception from HRESULT: 0x80073CFA) 
error 0x80070032: AppX Deployment Remove operation on package Microsoft.SecHealthUI_1000.27777.1008.0_x64__8wekyb3d8bbwe from: C:\Program Files\WindowsApps\Microsoft.SecHealthUI_1000.27777.1008.0_x64__8wekyb3d8bbwe failed. This app is part of Windows and cannot be uninstalled on a per-user basis. An administrator can attempt to remove the app from the computer using Turn Windows Features on or off. However, it may not be possible to uninstall the app. 
NOTE: For additional information, look for [ActivityId] c1198cb3-c10c-0000-4588-1ac10cc1db01 in the Event Log or use the command line Get-AppPackageLog -ActivityID c1198cb3-c10c-0000-4588-1ac10cc1db01 
At line:1 char:1  
+ Remove-AppxPackage -Package 'Microsoft.SecHealthUI_1000.27777.1008.0_ ...  
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~       
    + CategoryInfo          : WriteError: (Microsoft.SecHe...__8wekyb3d8bbwe:String) [Remove-AppxPackage], IOException      
    + FullyQualifiedErrorId : DeploymentError,Microsoft.Windows.Appx.PackageManager.Commands.RemoveAppxPackageCommand  

In case you're wondering, the E:\AnswerFiles\unattendGeneralizeOnly.xml just basically turns on PersistAllDeviceInstalls and DoNotCleanUpNonPresentDevices (in the 'Microsoft-Windows-PnpSysprep' component), and addresses only the 'generalize' pass.

So how do I proceed to generalizing?

Windows for business | Windows Client for IT Pros | User experience | Other

2 answers

Sort by: Most helpful
  1. Giuseppe Pacetti 0 Reputation points Microsoft Employee
    2025-07-31T15:03:57.93+00:00

    PS C:\temp> Remove-AppxProvisionedPackage -online -allusers -PackageName Microsoft.SecHealthUI_1000.27777.1008.0_x64__8wekyb3d8bbwe

    Remove-AppxProvisionedPackage : Removal failed. Please contact your software vendor.

    At line:1 char:1

    • Remove-AppxProvisionedPackage -online -allusers -PackageName Microsof ...
    • 
          + CategoryInfo          : NotSpecified: (:) [Remove-AppxProvisionedPackage], COMException
      
          + FullyQualifiedErrorId : Microsoft.Dism.Commands.RemoveAppxProvisionedPackageCommand
      
      

    Was this answer helpful?

    0 comments No comments

  2. Beatrix 2,290 Reputation points Independent Advisor
    2025-05-18T16:15:17.4033333+00:00

    Hi Keith,

    I've reviewed the sysprep logs, in this scenario, please use this command instead, because it's a provisioned package:

    Remove-AppxProvisionedPackage -online -allusers -PackageName Microsoft.SecHealthUI_1000.27777.1008.0_x64__8wekyb3d8bbwe

    Just a side note, you will probably have to do this several times before sysprep will run, give it a go and let me know how it went.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.