diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4cc57e1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +PSGetModuleInfo.xml +README.md +README.md diff --git a/Private/AllFunctions.ps1 b/Private/AllFunctions.ps1 index c325c09..8359af8 100644 --- a/Private/AllFunctions.ps1 +++ b/Private/AllFunctions.ps1 @@ -19,9 +19,16 @@ function Add-ContentADKWinPE { Write-Verbose "CurrentLog: $CurrentLog" Write-Host -ForegroundColor Gray " $SetOSDBuilderPathContent\$PackagePath" - Try {Add-WindowsPackage -PackagePath "$SetOSDBuilderPathContent\$PackagePath" -Path "$MountWinPE" -LogPath "$CurrentLog" | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountWinPE" /Add-Package /PackagePath:"$SetOSDBuilderPathContent\$PackagePath" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } @@ -34,9 +41,16 @@ function Add-ContentADKWinPE { Write-Verbose "CurrentLog: $CurrentLog" Write-Host -ForegroundColor Gray " $SetOSDBuilderPathContent\$PackagePath" - Try {Add-WindowsPackage -PackagePath "$SetOSDBuilderPathContent\$PackagePath" -Path "$MountWinPE" -LogPath "$CurrentLog" | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountWinPE" /Add-Package /PackagePath:"$SetOSDBuilderPathContent\$PackagePath" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } @@ -50,9 +64,16 @@ function Add-ContentADKWinPE { if ($OSMajorVersion -eq 6) { dism /Image:"$MountWinPE" /Add-Package /PackagePath:"$SetOSDBuilderPathContent\$PackagePath" /LogPath:"$CurrentLog" } else { - Try {Add-WindowsPackage -PackagePath "$SetOSDBuilderPathContent\$PackagePath" -Path "$MountWinPE" -LogPath "$CurrentLog" | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountWinPE" /Add-Package /PackagePath:"$SetOSDBuilderPathContent\$PackagePath" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } @@ -79,9 +100,16 @@ function Add-ContentADKWinRE { if ($PackagePath -like "*WinPE-NetFx*") { Write-Host -ForegroundColor Gray " $SetOSDBuilderPathContent\$PackagePath" - Try {Add-WindowsPackage -PackagePath "$SetOSDBuilderPathContent\$PackagePath" -Path "$MountWinRE" -LogPath "$CurrentLog" | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountWinRE" /Add-Package /PackagePath:"$SetOSDBuilderPathContent\$PackagePath" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } @@ -94,9 +122,16 @@ function Add-ContentADKWinRE { if ($PackagePath -like "*WinPE-PowerShell*") { Write-Host -ForegroundColor Gray " $SetOSDBuilderPathContent\$PackagePath" - Try {Add-WindowsPackage -PackagePath "$SetOSDBuilderPathContent\$PackagePath" -Path "$MountWinRE" -LogPath "$CurrentLog" | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountWinRE" /Add-Package /PackagePath:"$SetOSDBuilderPathContent\$PackagePath" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } @@ -110,9 +145,16 @@ function Add-ContentADKWinRE { if ($OSMajorVersion -eq 6) { dism /Image:"$MountWinRE" /Add-Package /PackagePath:"$SetOSDBuilderPathContent\$PackagePath" /LogPath:"$CurrentLog" } else { - Try {Add-WindowsPackage -PackagePath "$SetOSDBuilderPathContent\$PackagePath" -Path "$MountWinRE" -LogPath "$CurrentLog" | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountWinRE" /Add-Package /PackagePath:"$SetOSDBuilderPathContent\$PackagePath" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } @@ -142,9 +184,16 @@ function Add-ContentADKWinSE { if ($PackagePath -like "*WinPE-NetFx*") { Write-Host -ForegroundColor Gray " $SetOSDBuilderPathContent\$PackagePath" - Try {Add-WindowsPackage -PackagePath "$SetOSDBuilderPathContent\$PackagePath" -Path "$MountWinSE" -LogPath "$CurrentLog" | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountWinSE" /Add-Package /PackagePath:"$SetOSDBuilderPathContent\$PackagePath" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } @@ -156,9 +205,16 @@ function Add-ContentADKWinSE { if ($PackagePath -like "*WinPE-PowerShell*") { Write-Host -ForegroundColor Gray " $SetOSDBuilderPathContent\$PackagePath" - Try {Add-WindowsPackage -PackagePath "$SetOSDBuilderPathContent\$PackagePath" -Path "$MountWinSE" -LogPath "$CurrentLog" | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountWinSE" /Add-Package /PackagePath:"$SetOSDBuilderPathContent\$PackagePath" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } @@ -172,9 +228,16 @@ function Add-ContentADKWinSE { if ($OSMajorVersion -eq 6) { dism /Image:"$MountWinSE" /Add-Package /PackagePath:"$SetOSDBuilderPathContent\$PackagePath" /LogPath:"$CurrentLog.log" } else { - Try {Add-WindowsPackage -PackagePath "$SetOSDBuilderPathContent\$PackagePath" -Path "$MountWinSE" -LogPath "$CurrentLog" | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountWinSE" /Add-Package /PackagePath:"$SetOSDBuilderPathContent\$PackagePath" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } @@ -1064,10 +1127,15 @@ function Add-ContentPackOSLanguageFeatures { if ($MountDirectory) { Try { $global:ReapplyLCU = $true - Add-WindowsPackage -PackagePath "$($OSLanguageFeaturesFile.FullName)" -Path "$MountDirectory" -LogPath $CurrentLog | Out-Null + $DismResult = & dism.exe /Image:"$MountDirectory" /Add-Package /PackagePath:"$($OSLanguageFeaturesFile.FullName)" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } @@ -1102,9 +1170,16 @@ function Add-ContentPackOSLanguagePacks { Write-Host "$($OSLanguagePacksFile.FullName)" -ForegroundColor DarkGray if ($MountDirectory) { - Try {Add-WindowsPackage -PackagePath "$($OSLanguagePacksFile.FullName)" -Path "$MountDirectory" -LogPath $CurrentLog | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountDirectory" /Add-Package /PackagePath:"$($OSLanguagePacksFile.FullName)" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } @@ -1179,10 +1254,15 @@ function Add-ContentPackOSPackages { if ($MountDirectory) { Try { $global:ReapplyLCU = $true - Add-WindowsPackage -PackagePath "$($item.FullName)" -Path "$MountDirectory" -LogPath $CurrentLog | Out-Null + $DismResult = & dism.exe /Image:"$MountDirectory" /Add-Package /PackagePath:"$($item.FullName)" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } @@ -1443,11 +1523,15 @@ function Add-ContentPackPEADK { Write-Host -ForegroundColor Cyan " $($ADKFile.Name)" if ($MountDirectory) { Try { - Add-WindowsPackage -PackagePath "$($ADKFile.FullName)" -Path "$MountDirectory" -LogPath "$CurrentLog" | Out-Null + $DismResult = & dism.exe /Image:"$MountDirectory" /Add-Package /PackagePath:"$($ADKFile.FullName)" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} - + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } @@ -1458,10 +1542,16 @@ function Add-ContentPackPEADK { Write-Verbose "CurrentLog: $CurrentLog" Write-Host -ForegroundColor Cyan " $($ADKFile.Name)" if ($MountDirectory) { - Try {Add-WindowsPackage -PackagePath "$($ADKFile.FullName)" -Path "$MountDirectory" -LogPath "$CurrentLog" | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountDirectory" /Add-Package /PackagePath:"$($ADKFile.FullName)" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} - + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } @@ -1472,10 +1562,16 @@ function Add-ContentPackPEADK { Write-Verbose "CurrentLog: $CurrentLog" Write-Host -ForegroundColor Cyan " $($ADKFile.Name)" if ($MountDirectory) { - Try {Add-WindowsPackage -PackagePath "$($ADKFile.FullName)" -Path "$MountDirectory" -LogPath "$CurrentLog" | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountDirectory" /Add-Package /PackagePath:"$($ADKFile.FullName)" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} - + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } @@ -1486,10 +1582,16 @@ function Add-ContentPackPEADK { Write-Verbose "CurrentLog: $CurrentLog" Write-Host -ForegroundColor Cyan " $($ADKFile.Name)" if ($MountDirectory) { - Try {Add-WindowsPackage -PackagePath "$($ADKFile.FullName)" -Path "$MountDirectory" -LogPath "$CurrentLog" | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountDirectory" /Add-Package /PackagePath:"$($ADKFile.FullName)" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} - + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } @@ -1502,30 +1604,45 @@ function Add-ContentPackPEADK { if ($MountWinPE) { $CurrentLog = "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-ContentPackPEADK-$($ADKFile.Name).log" Try { - Add-WindowsPackage -PackagePath "$($ADKFile.FullName)" -Path "$MountWinPE" -LogPath "$CurrentLog" | Out-Null + $DismResult = & dism.exe /Image:"$MountWinPE" /Add-Package /PackagePath:"$($ADKFile.FullName)" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } if ($MountWinRE) { $CurrentLog = "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-ContentPackPEADK-$($ADKFile.Name).log" Try { - Add-WindowsPackage -PackagePath "$($ADKFile.FullName)" -Path "$MountWinRE" -LogPath "$CurrentLog" | Out-Null + $DismResult = & dism.exe /Image:"$MountWinRE" /Add-Package /PackagePath:"$($ADKFile.FullName)" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } if ($MountWinSE) { $CurrentLog = "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-ContentPackPEADK-$($ADKFile.Name).log" Try { - Add-WindowsPackage -PackagePath "$($ADKFile.FullName)" -Path "$MountWinSE" -LogPath "$CurrentLog" | Out-Null + $DismResult = & dism.exe /Image:"$MountWinSE" /Add-Package /PackagePath:"$($ADKFile.FullName)" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } @@ -1540,10 +1657,15 @@ function Add-ContentPackPEADK { $CurrentLog = "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-ContentPackPEADK-$($ADKFile.Name).log" Write-Host -ForegroundColor Cyan " $($ADKFile.Name) (WinPE)" Try { - Add-WindowsPackage -PackagePath "$($ADKFile.FullName)" -Path "$MountWinPE" -LogPath "$CurrentLog" | Out-Null + $DismResult = & dism.exe /Image:"$MountWinPE" /Add-Package /PackagePath:"$($ADKFile.FullName)" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } @@ -1553,10 +1675,15 @@ function Add-ContentPackPEADK { $CurrentLog = "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-ContentPackPEADK-$($ADKFile.Name).log" Write-Host -ForegroundColor Cyan " $($ADKFile.Name) (WinRE)" Try { - Add-WindowsPackage -PackagePath "$($ADKFile.FullName)" -Path "$MountWinRE" -LogPath "$CurrentLog" | Out-Null + $DismResult = & dism.exe /Image:"$MountWinRE" /Add-Package /PackagePath:"$($ADKFile.FullName)" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } @@ -1566,10 +1693,15 @@ function Add-ContentPackPEADK { $CurrentLog = "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-ContentPackPEADK-$($ADKFile.Name).log" Write-Host -ForegroundColor Cyan " $($ADKFile.Name) (WinSE)" Try { - Add-WindowsPackage -PackagePath "$($ADKFile.FullName)" -Path "$MountWinSE" -LogPath "$CurrentLog" | Out-Null + $DismResult = & dism.exe /Image:"$MountWinSE" /Add-Package /PackagePath:"$($ADKFile.FullName)" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } @@ -1580,10 +1712,15 @@ function Add-ContentPackPEADK { $CurrentLog = "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-ContentPackPEADK-$($ADKFile.Name).log" Write-Host -ForegroundColor Cyan " $($ADKFile.Name) (WinPE)" Try { - Add-WindowsPackage -PackagePath "$($ADKFile.FullName)" -Path "$MountWinPE" -LogPath "$CurrentLog" | Out-Null + $DismResult = & dism.exe /Image:"$MountWinPE" /Add-Package /PackagePath:"$($ADKFile.FullName)" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } @@ -1593,10 +1730,15 @@ function Add-ContentPackPEADK { $CurrentLog = "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-ContentPackPEADK-$($ADKFile.Name).log" Write-Host -ForegroundColor Cyan " $($ADKFile.Name) (WinRE)" Try { - Add-WindowsPackage -PackagePath "$($ADKFile.FullName)" -Path "$MountWinRE" -LogPath "$CurrentLog" | Out-Null + $DismResult = & dism.exe /Image:"$MountWinRE" /Add-Package /PackagePath:"$($ADKFile.FullName)" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } @@ -1606,10 +1748,15 @@ function Add-ContentPackPEADK { $CurrentLog = "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-ContentPackPEADK-$($ADKFile.Name).log" Write-Host -ForegroundColor Cyan " $($ADKFile.Name) (WinSE)" Try { - Add-WindowsPackage -PackagePath "$($ADKFile.FullName)" -Path "$MountWinSE" -LogPath "$CurrentLog" | Out-Null + $DismResult = & dism.exe /Image:"$MountWinSE" /Add-Package /PackagePath:"$($ADKFile.FullName)" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } @@ -2025,10 +2172,15 @@ function Add-FeaturesOnDemandOS { $CurrentLog = "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Add-FeaturesOnDemandOS.log" Write-Verbose "CurrentLog: $CurrentLog" Try { - Add-WindowsPackage -Path "$MountDirectory" -PackagePath "$SetOSDBuilderPathContent\$FOD" -LogPath "$CurrentLog" | Out-Null + $DismResult = & dism.exe /Image:"$MountDirectory" /Add-Package /PackagePath:"$SetOSDBuilderPathContent\$FOD" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "OSDBuilder: Review the log for more information" -Verbose Write-Verbose "$CurrentLog" -Verbose } @@ -2058,9 +2210,16 @@ function Add-LanguageFeaturesOnDemandOS { Write-Host " $SetOSDBuilderPathContent\$Update" -ForegroundColor DarkGray $CurrentLog = "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Add-LanguageFeaturesOnDemandOS.log" - Try {Add-WindowsPackage -Path "$MountDirectory" -PackagePath "$SetOSDBuilderPathContent\$Update" -LogPath $CurrentLog | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountDirectory" /Add-Package /PackagePath:"$SetOSDBuilderPathContent\$Update" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } @@ -2071,9 +2230,16 @@ function Add-LanguageFeaturesOnDemandOS { Write-Host " $SetOSDBuilderPathContent\$Update" -ForegroundColor DarkGray $CurrentLog = "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Add-LanguageFeaturesOnDemandOS.log" - Try {Add-WindowsPackage -Path "$MountDirectory" -PackagePath "$SetOSDBuilderPathContent\$Update" -LogPath $CurrentLog | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountDirectory" /Add-Package /PackagePath:"$SetOSDBuilderPathContent\$Update" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } @@ -2084,9 +2250,16 @@ function Add-LanguageFeaturesOnDemandOS { Write-Host " $SetOSDBuilderPathContent\$Update" -ForegroundColor DarkGray $CurrentLog = "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Add-LanguageFeaturesOnDemandOS.log" - Try {Add-WindowsPackage -Path "$MountDirectory" -PackagePath "$SetOSDBuilderPathContent\$Update" -LogPath $CurrentLog | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountDirectory" /Add-Package /PackagePath:"$SetOSDBuilderPathContent\$Update" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } @@ -2115,10 +2288,15 @@ function Add-LanguageInterfacePacksOS { $CurrentLog = "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Add-LanguageInterfacePacksOS.log" Try { $global:ReapplyLCU = $true - Add-WindowsPackage -Path "$MountDirectory" -PackagePath "$SetOSDBuilderPathContent\$Update" -LogPath $CurrentLog | Out-Null + $DismResult = & dism.exe /Image:"$MountDirectory" /Add-Package /PackagePath:"$SetOSDBuilderPathContent\$Update" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } else { @@ -2150,11 +2328,15 @@ function Add-LanguagePacksOS { $CurrentLog = "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Add-LanguagePacksOS.log" Try { $global:ReapplyLCU = $true - Add-WindowsPackage -Path "$MountDirectory" -PackagePath "$SetOSDBuilderPathContent\$Update" -LogPath $CurrentLog | Out-Null + $DismResult = & dism.exe /Image:"$MountDirectory" /Add-Package /PackagePath:"$SetOSDBuilderPathContent\$Update" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} - + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } elseif ($Update -like "*.appx") { @@ -2211,10 +2393,15 @@ function Add-WindowsPackageOS { $CurrentLog = "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Add-WindowsPackageOS.log" Try { $global:ReapplyLCU = $true - Add-WindowsPackage -PackagePath "$SetOSDBuilderPathContent\$PackagePath" -Path "$MountDirectory" -LogPath $CurrentLog | Out-Null + $DismResult = & dism.exe /Image:"$MountDirectory" /Add-Package /PackagePath:"$SetOSDBuilderPathContent\$PackagePath" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "OSDBuilder: Review the log for more information" -Verbose Write-Verbose "$CurrentLog" -Verbose } @@ -3098,7 +3285,7 @@ function Get-OSDUpdateDownloads { } else { #PowerShell ISE will display a NativeCommandError, so progress will not be displayed - $Quiet = Invoke-Expression "& curl.exe --insecure --location --output `"$DownloadFullPath`" --url `"$SourceUrl`" 2>&1" + $Quiet = Invoke-Expression "& curl.exe --insecure --location --output `"$DownloadFullPath`" --url `"$SourceUrl`"" } } else { @@ -3135,7 +3322,10 @@ function Get-OSDUpdates { } $UpdateBuild = $null - if ($Item.Title -match '25H2') { + if ($Item.Title -match '26H2') { + $UpdateBuild = '26H2' + } + elseif ($Item.Title -match '25H2') { $UpdateBuild = '25H2' } elseif ($Item.Title -match '24H2') { @@ -6607,9 +6797,16 @@ function Update-AdobeOS { $CurrentLog = "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Update-AdobeOS-KB$($Update.FileKBNumber).log" Write-Verbose "CurrentLog: $CurrentLog" - Try {Add-WindowsPackage -Path "$MountDirectory" -PackagePath "$UpdateASU" -LogPath $CurrentLog | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountDirectory" /Add-Package /PackagePath:"$UpdateASU" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "OSDBuilder: Review the log for more information" -Verbose Write-Verbose "$CurrentLog" -Verbose } @@ -6658,9 +6855,16 @@ function Update-ComponentOS { $CurrentLog = "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Update-ComponentOS-KB$($Update.FileKBNumber).log" Write-Verbose "CurrentLog: $CurrentLog" - Try {Add-WindowsPackage -Path "$MountDirectory" -PackagePath "$UpdateComp" -LogPath "$CurrentLog" | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountDirectory" /Add-Package /PackagePath:"$UpdateComp" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "OSDBuilder: Review the log for more information" -Verbose Write-Verbose "$CurrentLog" -Verbose } @@ -6748,7 +6952,14 @@ function Update-CumulativeOS { $CurrentLog = "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Update-CumulativeOS-KB$($Update.FileKBNumber).log" Write-Verbose "CurrentLog: $CurrentLog" - Try {Add-WindowsPackage -Path "$MountDirectory" -PackagePath "$UpdateLCU" -LogPath "$CurrentLog" -Verbose | Out-Null} + Try { + & dism.exe /Image:"$MountDirectory" /Add-Package /PackagePath:"$UpdateLCU" /LogPath:"$CurrentLog" /PreventPending + if ($LASTEXITCODE -eq 0x800f081e) {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($LASTEXITCODE -eq 0x800f0998) {Write-Verbose "OSDBuilder: 0x800f0998 The package may require an SSU installed first" -Verbose} + if ($LASTEXITCODE -eq 0x8007007b) {Write-Verbose "OSDBuilder: 0x8007007b This is a bug that Manel Rodero first spotted, working on it" -Verbose} + if ($LASTEXITCODE -ne 0) {Write-Verbose "OSDBuilder: Review the log for more information" -Verbose} + if ($LASTEXITCODE -ne 0) {Write-Verbose "$CurrentLog" -Verbose} + } Catch { if ($_.Exception.Message -match '0x800f081e') { Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose @@ -6823,9 +7034,16 @@ function Update-CumulativePE { $CurrentLog = "$PEInfo\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Update-CumulativePE-KB$($Update.KBNumber)-WinPE.log" Write-Verbose "CurrentLog: $CurrentLog" - Try {Add-WindowsPackage -Path "$MountWinPE" -PackagePath "$UpdateLCU" -LogPath "$CurrentLog" | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountWinPE" /Add-Package /PackagePath:"$UpdateLCU" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "OSDBuilder: Review the log for more information" -Verbose Write-Verbose "$CurrentLog" -Verbose } @@ -6864,9 +7082,16 @@ function Update-CumulativePE { $CurrentLog = "$PEInfo\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Update-CumulativePE-KB$($Update.KBNumber)-WinRE.log" Write-Verbose "CurrentLog: $CurrentLog" - Try {Add-WindowsPackage -Path "$MountWinRE" -PackagePath "$UpdateLCU" -LogPath "$CurrentLog" | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountWinRE" /Add-Package /PackagePath:"$UpdateLCU" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "OSDBuilder: Review the log for more information" -Verbose Write-Verbose "$CurrentLog" -Verbose } @@ -6908,9 +7133,16 @@ function Update-CumulativePE { $CurrentLog = "$PEInfo\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Update-CumulativePE-KB$($Update.KBNumber)-WinSE.log" Write-Verbose "CurrentLog: $CurrentLog" - Try {Add-WindowsPackage -Path "$MountWinSE" -PackagePath "$UpdateLCU" -LogPath "$CurrentLog" | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountWinSE" /Add-Package /PackagePath:"$UpdateLCU" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "OSDBuilder: Review the log for more information" -Verbose Write-Verbose "$CurrentLog" -Verbose } @@ -6969,9 +7201,16 @@ function Update-DotNetOS { $CurrentLog = "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Update-DotNetOS-KB$($Update.FileKBNumber).log" Write-Verbose "CurrentLog: $CurrentLog" - Try {Add-WindowsPackage -Path "$MountDirectory" -PackagePath "$UpdateNetCU" -LogPath "$CurrentLog" | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountDirectory" /Add-Package /PackagePath:"$UpdateNetCU" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } if ($_.Exception.Message -match '0x8007371b') { Write-Verbose "OSDBuilder: 0x8007371b ERROR_SXS_TRANSACTION_CLOSURE_INCOMPLETE" -Verbose Write-Verbose "One or more required members of the transaction are not present" -Verbose @@ -7003,7 +7242,12 @@ function Update-DotNetOS { $CurrentLog = "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Update-DotNetOS-KB$($Update.FileKBNumber).log" Write-Verbose "CurrentLog: $CurrentLog" - Try {Add-WindowsPackage -Path "$MountDirectory" -PackagePath "$UpdateNetCU" -LogPath "$CurrentLog" | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountDirectory" /Add-Package /PackagePath:"$UpdateNetCU" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { if ($_.Exception.Message -match '0x800f081e') { Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose @@ -7152,9 +7396,16 @@ function Update-OptionalOS { $CurrentLog = "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Update-OptionalOS-KB$($Update.FileKBNumber).log" Write-Verbose "CurrentLog: $CurrentLog" - Try {Add-WindowsPackage -Path "$MountDirectory" -PackagePath "$UpdateOptional" -LogPath "$CurrentLog" | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountDirectory" /Add-Package /PackagePath:"$UpdateOptional" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "$CurrentLog" -Verbose } } @@ -7203,9 +7454,16 @@ function Update-ServicingStackOS { $CurrentLog = "$Info\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Update-ServicingStackOS-KB$($Update.FileKBNumber).log" Write-Verbose "CurrentLog: $CurrentLog" - Try {Add-WindowsPackage -Path "$MountDirectory" -PackagePath "$UpdateSSU" -LogPath "$CurrentLog" | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountDirectory" /Add-Package /PackagePath:"$UpdateSSU" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "OSDBuilder: Review the log for more information" -Verbose Write-Verbose "$CurrentLog" -Verbose } @@ -7259,9 +7517,16 @@ function Update-ServicingStackPE { $CurrentLog = "$PEInfo\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Update-ServicingStackPE-KB$($Update.KBNumber)-WinPE.log" Write-Verbose "CurrentLog: $CurrentLog" - Try {Add-WindowsPackage -Path "$MountWinPE" -PackagePath "$UpdateSSU" -LogPath "$CurrentLog" | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountWinPE" /Add-Package /PackagePath:"$UpdateSSU" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "OSDBuilder: Review the log for more information" -Verbose Write-Verbose "$CurrentLog" -Verbose } @@ -7290,12 +7555,19 @@ function Update-ServicingStackPE { $CurrentLog = "$PEInfo\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Update-ServicingStackPE-KB$($Update.KBNumber)-WinRE.log" Write-Verbose "CurrentLog: $CurrentLog" - Try {Add-WindowsPackage -Path "$MountWinRE" -PackagePath "$UpdateSSU" -LogPath "$CurrentLog" | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountWinRE" /Add-Package /PackagePath:"$UpdateSSU" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { $ErrorMessage = $_.Exception.$ErrorMessage Write-Warning "$CurrentLog" Write-Host "$ErrorMessage" - if ($ErrorMessage -like "*0x800f081e*") {Write-Warning "Update not applicable to this Operating System"} + if ($ErrorMessage -like "*0x800f081e*") { + Write-Warning "Update not applicable to this Operating System" + } } } #================================================= @@ -7322,9 +7594,16 @@ function Update-ServicingStackPE { $CurrentLog = "$PEInfo\logs\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Update-ServicingStackPE-KB$($Update.KBNumber)-WinSE.log" Write-Verbose "CurrentLog: $CurrentLog" - Try {Add-WindowsPackage -Path "$MountWinSE" -PackagePath "$UpdateSSU" -LogPath "$CurrentLog" | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountWinSE" /Add-Package /PackagePath:"$UpdateSSU" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "OSDBuilder: Review the log for more information" -Verbose Write-Verbose "$CurrentLog" -Verbose } @@ -7491,9 +7770,16 @@ function Update-WindowsServer2012R2OS { Write-Host -ForegroundColor Gray "$($Update.Title) - $(Split-Path $Update.OriginUri -Leaf)" Write-Verbose "CurrentLog: $CurrentLog" - Try {Add-WindowsPackage -Path "$MountDirectory" -PackagePath "$UpdateTwelveR2" -LogPath "$CurrentLog" | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountDirectory" /Add-Package /PackagePath:"$UpdateTwelveR2" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "OSDBuilder: Review the log for more information" -Verbose Write-Verbose "$CurrentLog" -Verbose } @@ -7572,9 +7858,16 @@ function Update-WindowsSevenOS { Write-Host -ForegroundColor Gray "$($Update.Title) - $(Split-Path $Update.OriginUri -Leaf)" Write-Verbose "CurrentLog: $CurrentLog" - Try {Add-WindowsPackage -Path "$MountDirectory" -PackagePath "$UpdateSeven" -LogPath "$CurrentLog" | Out-Null} + Try { + $DismResult = & dism.exe /Image:"$MountDirectory" /Add-Package /PackagePath:"$UpdateSeven" /LogPath:"$CurrentLog" + if ($LASTEXITCODE -ne 0) { + throw "DISM exited with code $LASTEXITCODE`: $DismResult" + } + } Catch { - if ($_.Exception.Message -match '0x800f081e') {Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose} + if ($_.Exception.Message -match '0x800f081e') { + Write-Verbose "OSDBuilder: 0x800f081e The package is not applicable to this image" -Verbose + } Write-Verbose "OSDBuilder: Review the log for more information" -Verbose Write-Verbose "$CurrentLog" -Verbose } diff --git a/Public/Get-OSBuilds.ps1 b/Public/Get-OSBuilds.ps1 index b43a671..927a1ce 100644 --- a/Public/Get-OSBuilds.ps1 +++ b/Public/Get-OSBuilds.ps1 @@ -30,7 +30,7 @@ function Get-OSBuilds { [string]$OSMajorVersion, #Filter the OSBuild by OS Release Id - [ValidateSet ('24H2','23H2','22H2','21H2','21H1','20H2',2004,1909,1903,1809)] + [ValidateSet ('26H2','25H2','24H2','23H2','22H2','21H2','21H1','20H2',2004,1909,1903,1809)] [string]$OSReleaseId, #Filter the OSBuild by Image Revision diff --git a/Public/Import-OSMedia.ps1 b/Public/Import-OSMedia.ps1 index bf0e9a7..5341e7c 100644 --- a/Public/Import-OSMedia.ps1 +++ b/Public/Import-OSMedia.ps1 @@ -207,7 +207,7 @@ function Import-OSMedia { Show-ActionTime; Write-Host 'Get-OSDBuilder: Validating OSDBuilder Content' Show-ActionTime; Write-Warning 'This version of OSDBuilder supports:' Show-ActionTime; Write-Warning 'Windows 10 1607 - 21H2 x64' - Show-ActionTime; Write-Warning 'Windows 11 21H2 - 24H2 x64' + Show-ActionTime; Write-Warning 'Windows 11 21H2 - 26H2 x64' #Show-ActionTime; Write-Warning 'Windows Server 2016 1607 - Windows Server 2022 21H1' Get-OSDBuilder -CreatePaths -HideDetails #================================================= @@ -529,6 +529,10 @@ function Import-OSMedia { $GetWindowsImage | ConvertTo-Json | Out-File "$OSMediaPathInfo\json\$((Get-Date).ToString('yyyy-MM-dd-HHmmss'))-Get-WindowsImage.json" (Get-Content "$OSMediaPath\WindowsImage.txt") | Where-Object {$_.Trim(" `t")} | Set-Content "$OSMediaPath\WindowsImage.txt" #================================================= + Write-Verbose 'Remove Temporary Folder' + #================================================= + if (Test-Path "$MountDirectory") {Remove-Item -Path "$MountDirectory" -Force -Recurse | Out-Null} + #================================================= # OSD-Export #================================================= Save-OSMediaWindowsImageContent diff --git a/Public/New-OSBuildMultiLang.ps1 b/Public/New-OSBuildMultiLang.ps1 index 72ae85b..4ddb9d6 100644 --- a/Public/New-OSBuildMultiLang.ps1 +++ b/Public/New-OSBuildMultiLang.ps1 @@ -45,7 +45,7 @@ function New-OSBuildMultiLang { Write-Warning "OSBuild MultiLang will take an OSBuild with Language Packs" Write-Warning "and create a new OSBuild with multiple Indexes" Write-Warning "Each Index will have a Language set as the System UI" - Write-Warning "This process will take some time as the LCU will be reapplied" + # Write-Warning "This process will take some time as the DotNet & LCU will be reapplied" #================================================= # Get OSBuilds with Multi Lang @@ -98,7 +98,7 @@ function New-OSBuildMultiLang { $OSBuild = $($LangMultiWindowsImage.Build) $OSInstallationType = $($LangMultiWindowsImage.InstallationType) $OSMajorVersion = $($LangMultiWindowsImage.MajorVersion) - $WindowsImageMediaName = $($LangMultiWindowsImage.MediaName) + $WindowsImageMediaName = $($LangMultiWindowsImage.ImageName) $OSVersion = $($LangMultiWindowsImage.Version) if ($OSArchitecture -eq '0') {$OSArchitecture = 'x86'} @@ -123,6 +123,14 @@ function New-OSBuildMultiLang { } } #================================================= + # OSDUpdateDotNet + #================================================= + $OSDUpdateDotNet = $AllOSDUpdates + $OSDUpdateDotNet = $OSDUpdateDotNet | Where-Object {$_.UpdateArch -eq $OSArchitecture} + $OSDUpdateDotNet = $OSDUpdateDotNet | Where-Object {$_.UpdateOS -eq $UpdateOS} + $OSDUpdateDotNet = $OSDUpdateDotNet | Where-Object {($_.UpdateBuild -eq $ReleaseId) -or ($_.UpdateBuild -eq '')} + $OSDUpdateDotNet = $OSDUpdateDotNet | Where-Object {$_.UpdateGroup -like 'DotNet*'} + #================================================= # OSDUpdateLCU #================================================= $OSDUpdateLCU = $AllOSDUpdates @@ -149,7 +157,7 @@ function New-OSBuildMultiLang { # Process Indexes #================================================= foreach ($LangMultiLanguage in $LangMultiLanguages) { - if ($LangMultiLanguage -eq $LangMultiDefaultName) { + if ($LangMultiLanguage -eq $LangMultiDefaultName) { #================================================= # Header #================================================= @@ -157,17 +165,21 @@ function New-OSBuildMultiLang { Write-Host -ForegroundColor Green "$($Media.ImageName) $LangMultiDefaultName is already processed as Index 1" } else { Show-ActionTime - Write-Host -ForegroundColor Green "Processing $($Media.ImageName) $LangMultiLanguage" + Write-Host -ForegroundColor Green "Processing $($Media.ImageName) $LangMultiLanguage" Write-Host "Dism /Image:"$MountDirectory" /Set-AllIntl:$LangMultiLanguage" -ForegroundColor Cyan Dism /Image:"$MountDirectory" /Set-AllIntl:$LangMultiLanguage Write-Host "Dism /Image:"$MountDirectory" /Get-Intl" -ForegroundColor Cyan Dism /Image:"$MountDirectory" /Get-Intl + + # Write-Warning "Waiting 10 seconds for processes to complete before applying DotNet ..." + # Start-Sleep -Seconds 10 + # Update-DotNetOS -Force - Write-Warning "Waiting 10 seconds for processes to complete before applying LCU ..." - Start-Sleep -Seconds 10 - Update-CumulativeOS -Force + # Write-Warning "Waiting 10 seconds for processes to complete before applying LCU ..." + # Start-Sleep -Seconds 10 + # Update-CumulativeOS -Force Write-Warning "Waiting 10 seconds for processes to complete before Save-WindowsImage ..." Start-Sleep -Seconds 10 @@ -179,6 +191,35 @@ function New-OSBuildMultiLang { } } #================================================= + # Index Rename + #================================================= + # Retrieve index numbers + $ImageCount = (wimlib-imagex info "$DestinationFullName\OS\Sources\install.wim" | Select-String "Image Count:" | ForEach-Object { $_ -replace "Image Count:\s+", "" }).Trim() + + for ($Index = 1; $Index -le [int]$ImageCount; $Index++) { + # retrieve wiminfo + $WimInfo = wimlib-imagex info "$DestinationFullName\OS\Sources\install.wim" $Index + + # Extract "Default Language" + $DefaultLang = ($WimInfo | Select-String "Default Language:" | ForEach-Object { $_ -replace "Default Language:\s+", "" }).Trim() + + # Extact "Display Name" + $DisplayName = ($WimInfo | Select-String "Display Name:" | ForEach-Object { $_ -replace "Display Name:\s+", "" }).Trim() + + # Extract "Display Description" + $DisplayDescription = ($WimInfo | Select-String "Display Description:" | ForEach-Object { $_ -replace "Display Description:\s+", "" }).Trim() + + # Extract "Description" + $Description = ($WimInfo | Select-String "^\s*Description:" | ForEach-Object { $_ -replace ".*Description:\s+", "" }).Trim() + + $DisplayName = "$DisplayName $DefaultLang" + $DisplayDescription = "$DisplayDescription $DefaultLang" + $Description = "$Description $DefaultLang" + + # Set new Display Name and Display Description + wimlib-imagex info "$DestinationFullName\OS\Sources\install.wim" $Index --image-property DISPLAYNAME="$DisplayName" --image-property DISPLAYDESCRIPTION="$DisplayDescription" --image-property DESCRIPTION="$Description" + } + #================================================= # Cleanup #================================================= try { diff --git a/Public/New-OSDBuilderISO.ps1 b/Public/New-OSDBuilderISO.ps1 index 16a908b..837ff7a 100644 --- a/Public/New-OSDBuilderISO.ps1 +++ b/Public/New-OSDBuilderISO.ps1 @@ -139,7 +139,10 @@ function New-OSDBuilderISO { $OSImageName = "Server $($Media.Version)" $ISOFile = "$ISODestinationFolder\Server $($Media.Version).iso" } else { - if ($Media.MajorVersion -eq 10) { + if ($Media.Build.SubString(0,1) -eq 2) { + $OSImageName = "Win11 $($Media.Arch) $($Media.ReleaseId) $($Media.UBR)" + $ISOFile = "$ISODestinationFolder\Win11 $($Media.Arch) $($Media.ReleaseId) $($Media.UBR).iso" + } elseif ($Media.Build.SubString(0,1) -eq 1) { $OSImageName = "Win10 $($Media.Arch) $($Media.ReleaseId) $($Media.UBR)" $ISOFile = "$ISODestinationFolder\Win10 $($Media.Arch) $($Media.ReleaseId) $($Media.UBR).iso" } elseif ($Media.Version -like "6.3.*") { diff --git a/Public/Save-OSDBuilderDownload.ps1 b/Public/Save-OSDBuilderDownload.ps1 index 06dd535..e2465c1 100644 --- a/Public/Save-OSDBuilderDownload.ps1 +++ b/Public/Save-OSDBuilderDownload.ps1 @@ -45,7 +45,7 @@ function Save-OSDBuilderDownload { #Feature Update Build [Parameter(ParameterSetName = 'FeatureUpdates')] - [ValidateSet ('24H2','23H2','22H2','21H2','21H1','20H2',2004,1909,1903,1809)] + [ValidateSet ('26H2','25H2','24H2','23H2','22H2','21H2','21H1','20H2',2004,1909,1903,1809)] [string]$FeatureBuild, #Feature Update Edition @@ -82,7 +82,7 @@ function Save-OSDBuilderDownload { #Filter Microsoft Updates for a specific ReleaseId [Parameter(ParameterSetName='OSDUpdate')] - [ValidateSet ('24H2','23H2','22H2','21H2','21H1','20H2',2004,1909,1903,1809,1803,1709,1703,1607,1511,1507,7601,7603)] + [ValidateSet ('26H2','25H2','24H2','23H2','22H2','21H2','21H1','20H2',2004,1909,1903,1809,1803,1709,1703,1607,1511,1507,7601,7603)] [Alias('ReleaseId')] [string]$UpdateBuild, diff --git a/README.md b/README.md index 633ce31..9ceb6b7 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,3 @@ # OSDBuilder - -January 21, 2025 -OSDBuilder is not working due to updates not being downloaded or installed. Unfortunately, I'm unable to resolve this and do not have an ETA. - -Feel free to post an Issue -https://github.com/OSDeploy/OSDBuilder/issues - -David Segura +PowerShell Module +https://osdbuilder.osdeploy.com \ No newline at end of file