MSEndpointMgr / ConfigMgr

Microsoft Endpoint Configuration Manager scripts and tools
634 stars 281 forks source link

Invoke-WindowsImageOfflineServicing.ps1 (v 1.1.5) - Failed to apply the .NET Framework Cumulative Update #225

Open aimar115 opened 4 years ago

aimar115 commented 4 years ago

Hello

When servicing 1809 Image I'm getting following error: WARNING: Failed to apply required patch in OS image for: C:\OSDImageServicing\Updates\windows10.0-kb4537480-x64-ndp48-1809-.NETFramework.cab WARNING: Failed to apply the .NET Framework Cumulative Update patches to OS image WARNING: [Servicing]: Windows image servicing failed, please refer to warning messages in the output stream

The update that it is tryng to apply is: http://download.windowsupdate.com/c/msdownload/update/software/updt/2020/02/windows10.0-kb4537480-x64-ndp48_f68b87215f4a2b081e3885171651eec50437e75e.cab

Error from DISM.log: CBS Appl: Evaluating package applicability for package Package_for_DotNetRollup~31bf3856ad364e35~amd64~~10.0.1.3143, applicable state: Absent DISM DISM Package Manager: PID=6348 TID=4440 Error in operation: the package is not applicable. (CBS HRESULT=0x800f081e) - CCbsConUIHandler::Error

First .NET Update is applyed successfully: http://download.windowsupdate.com/c/msdownload/update/software/updt/2020/02/windows10.0-kb4537490-x64_c82806ea982849c40759c6e9d1e8b98d2befa293.cab

Hope the provided information helps.

aimar115 commented 4 years ago

Found the culprit: it is KB4538156 Update that has 2 $UpdateItemContentIDs, one of those is kb4537480 what is not applicable for 1809 because 1809 does not have .net 4.8.

aimar115 commented 4 years ago

Made .NET Update selection dependent of the OS version and now it works.

# Determine .NET Framework Cumulative Update files to be applied IF($OSVersion -ge "1903"){ $NETFrameworkUpdateFilePaths = Get-ChildItem -Path $UpdateFilesRoot -Recurse -Filter "*NETFramework*.cab" | Sort-Object -Descending -Property $_.CreationTime | Select-Object -ExpandProperty FullName } Else{ $NETFrameworkUpdateFilePaths = Get-ChildItem -Path $UpdateFilesRoot -Recurse -Filter "*NETFramework*.cab"| Where-Object {$_.Name -notlike "*ndp48*"} | Sort-Object -Descending -Property $_.CreationTime | Select-Object -ExpandProperty FullName }

NickolajA commented 4 years ago

Use this much improved script instead: https://github.com/MSEndpointMgr/ConfigMgr/blob/master/Operating%20System%20Deployment/Windows%20Servicing/Invoke-WindowsImageServicing.ps1

Let me know how it goes. Version 1.1.5 is no longer being maintained, the new script is linked above.

aimar115 commented 4 years ago

Thank you for quick response.

Running now "Invoke-WindowsImageServicing.ps1" Version 2.1.0 script has not finished jet but already saw the same behavior(2 rows from verbose output):

VERBOSE:  - Selected the 'NETFramework' content cabinet file: C:\OSDImageServicing\Updates\windows10.0-kb4537490-x64-1809-NETFramework.cab
VERBOSE:  - Selected the 'NETFramework' content cabinet file: C:\OSDImageServicing\Updates\windows10.0-kb4537480-x64-ndp48-1809-NETFramework.cab

Windows 10 1809 does not have framework 4.8 therefore that last cab should not be selected. Other alternative is to upgrade framework to 4.8 before updating, Feature Pack for that is KB4486153. If its possible to include that also in Servicing that would be awesome.

NickolajA commented 4 years ago

It also includes improvements to 3.5 if that's enabled:

https://support.microsoft.com/en-us/help/4537480/kb4537480-cumulative-update-for-net-framework

Did 2.1.0 manage to inject that package?

aimar115 commented 4 years ago

Got same result with 2.1.0:

VERBOSE:  - Currently processing package: C:\OSDImageServicing\Updates\windows10.0-kb4537480-x64-ndp48-1809-NETFramework.cab
WARNING:  - Failed to apply '.NET Framework' package to OS image, see DISM.log for more details
WARNING:  - Failed to apply '.NET Framework' package to OS image. Error message: The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
WARNING: [ServicingFailed]: Windows image servicing failed, please refer to previous error or warning messages

I modified script so that 4.8 Update is not selected:

switch ($UpdateType) {
            "NETFramework" {
                IF($OSVersion -ge "1903"){
                    $UpdateFiles = Get-ChildItem -Path $UpdateFilesRoot -Recurse -Filter $UpdateFilter | Sort-Object -Descending -Property $_.CreationTime | Select-Object -ExpandProperty FullName
                }
                else {
                    $UpdateFiles = Get-ChildItem -Path $UpdateFilesRoot -Recurse -Filter $UpdateFilter |Where-Object {$_.Name -notlike "*ndp48*"}| Sort-Object -Descending -Property $_.CreationTime | Select-Object -ExpandProperty FullName
                }

As you see there are 2 .NET updates for 1809. First is KB4537490, that one is for 1809 with .NET Framework 3.5 and 4.7.2. Second is KB4537480, that one is for 1809 with .NET Framework 3.5 and 4.8.

The second one fails because .NET Framework 4.8 is not installed and therefore should not be selected by the script for installation.