DISM is a great tool to use for scripting updates to WIM or VHDX files.
Here’s how to get started for VHDX, VHD, or WIM files offline.
dism /mount-image /imagefile:boot.vhdx /mountdir:d:\mount /index:1
Here are a few tricks to remembering the syntax, minus using Google, most DISM commands that perform an action or verbs are separated with a hyphen, e.g., mount-image. The files and directories or nouns use only a single word, e.g., imagefile:, mountdir:.
Finding the indexes for WIM or install images:
dism /get-wiminfo /wimfile:Nanoserver.wim
Adding packages offline to NanoServer.VHDX files:
dism /mount-image /mountdir:d:\mount /imagefile:nanoserver.vhdx /index:1 (Mounts the only index of this installed Nano Image.)
dism /image:d:\mount /add-package /packagepath:d:\NanoServer\packages\Microsoft-NanoServer-Computer-Package.cab (Add this package to that NanoServer install)
dism /umount-image /mountdir:d:\mount /commit (Writes the changes)