Quantcast
Channel: Jay Connor – HappySCCM
Viewing all articles
Browse latest Browse all 108

Inject dot net 3.5 into Windows 11 wim before adding image to SCCM

$
0
0

Previously Windows has been ok with using a dot net package from a different month, so you could add it during the task sequence without much trouble. Now you need the right version. Best way to do this is have a process to inject the wim then copy it to the network folder.

Script lets you pick the iso, mounts it, extracts Enterprise Wim, injects dot net, copies wim to network folder. Then copies the wim path to clipboard

#File Picker
Function Get-FileName($initialDirectory)
{  
 [System.Reflection.Assembly]::LoadWithPartialName(“System.windows.forms”) |
 Out-Null

 $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
 $OpenFileDialog.initialDirectory = $initialDirectory
 $OpenFileDialog.filter = “Isos| *.iso”
 $OpenFileDialog.ShowDialog() | Out-Null
 $OpenFileDialog.filename
}

# Vars
$date = (Get-Date -UFormat "%d-%b-%Y")
$name = "Windows 11 22H2 Enterprise $date"
$networkFolder =  "\\NetworkPath\Windows 11 22H2\$name"

write-host "Choose Windows 11 ISO"
$iso = Get-FileName -initialDirectory “c:\users\connor\downloads”
$isoMount = Mount-DiskImage -ImagePath $iso -NoDriveLetter

#set up dirs
rmdir "$env:TEMP\Images\" -Force -recurse -ErrorAction SilentlyContinue
mkdir "$env:TEMP\Images\" -ErrorAction SilentlyContinue
mkdir "$env:TEMP\Images\mount"  -ErrorAction SilentlyContinue

#Export image
Export-WindowsImage -SourceImagePath "$($isoMount.DevicePath)\sources\install.wim" -SourceIndex 3 -DestinationImagePath "$env:TEMP\Images\install.wim" -DestinationName $name 

#mount new wim
Mount-WindowsImage -ImagePath "$env:TEMP\Images\install.wim" -Index 1 -Path "$env:TEMP\Images\mount"
#add dot net
Enable-WindowsOptionalFeature -Path "$env:TEMP\Images\mount" -FeatureName "NetFx3" -Source "$($isoMount.DevicePath)\sources\sxs\"
#unmount clean up
Dismount-WindowsImage -Path "$env:TEMP\Images\mount" -Save
mkdir "$networkFolder"
Copy-Item "$env:TEMP\Images\install.wim" $networkFolder
Dismount-DiskImage -DevicePath $isoMount.DevicePath
#copy path for CM
Set-clipboard -value "$networkFolder\Install.wim"

Viewing all articles
Browse latest Browse all 108

Trending Articles