Skip to content

Instantly share code, notes, and snippets.

@micahyoung
Last active October 29, 2019 00:52
Show Gist options
  • Save micahyoung/7e35bb285a22675117f13ec068c422fa to your computer and use it in GitHub Desktop.
Save micahyoung/7e35bb285a22675117f13ec068c422fa to your computer and use it in GitHub Desktop.
Patch offline image to match current

Get current OS image and buid number

systeminfo
#> OS Name:     Microsoft Windows Server 2019 Datacenter
#> OS Version:  10.0.17763 N/A Build 17763

Make patched source from older iso

  1. Get an ISO with same version but lower patch than current image

  2. Confirm iso version: Find Index of your product

dism /get-wiminfo /wimfile:d:\sources\install.wim
# Find matching index:
#  Index : 1
#  Name : Windows Server 2019 Datacenter

dism /get-wiminfo /wimfile:d:\sources\install.wim /index:1
# Find build: 
#  ServicePack Build : 379
  1. Export image
dism /export-image /sourceimagefile:d:\sources\install.wim /sourceindex:3 /destinationimagefile:c:\install-patched.wim /compress:max
  1. Mount the image for patching
mkdir c:\mount-wim
dism /mount-wim /wimfile:c:\install-patched.wim /index:1 /mountdir:c:\mount-wim
  1. Find service patch that defines your build number
dism /online /get-packages  | findstr "557"
#> Package Identity : Package_for_RollupFix~31bf3856ad364e35~amd64~~17763.557.1.7
  1. Get KB number for the matching package name
dism /online /get-packageinfo /packagename:Package_for_RollupFix~31bf3856ad364e35~amd64~~17763.557.1.7 | findstr /I "kb"
#> Description : Fix for KB4503327
#> Support Information : http://support.microsoft.com/?kbid=4503327
  1. Find KB patch
Install-PackageProvider -Name NuGet -Force
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Module kbupdate
get-kbupdate KB4503327 -Simple
  1. Extract cab from MSU
mkdir c:\patch-temp
get-kbupdate KB4503327 -Product "Windows Server 2019" | save-kbupdate -Path C:\patch-temp\
expand -f:* "C:\patch-temp\*.msu" c:\patch-temp
  1. Install patch to mounted image
dism /image:c:\mount-wim /add-package /packagepath:c:\patch-temp\Windows10.0-KB4503327-x64_PSFX.cab
  1. Install features from wim source
dism /online /enable-feature:AD-Domain-Services /source:c:\mount-wim\windows\winsxs
  1. Unmount and commit image
dism /unmount-wim /mountdir:c:\mount-wim /commit

Alternative: install from commited image directly

Install-WindowsFeature AD-Domain-Services,DNS -Source wim:c:\install-patched.wim:1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment