[SCCM] [Powershell] [BootImage] Extract and Configure SCCM WIM Boot Image
This script will extract the WIM file from the ISO boot image generated by SCCM. It then mounts, configures, and unmounts the WIM file so it is ready to push up to WDS.
| [CmdletBinding()] param ( [ValidateNotNullOrEmpty()] [string]$File = 'C:\WinPE\SCCM.iso' ) Import-Module Dism #Extract the name of the directory the $File resides in $Directory = $File.substring(0, $File.LastIndexOf('\')) #Mount and assign drive letter $Drive = ((Mount-DiskImage -ImagePath $File) | Get-Volume).DriveLetter #Delete old Mount directory Remove-Item -Path ($Directory + '\Mount') -Recurse -Force -ErrorAction SilentlyContinue #Create Mount folder to copy WIM contents to New-Item -Path ($Directory + '\Mount') -ItemType Directory -Force #Delete old WIM file Remove-Item -Path ($Directory + '\boot.wim') -ErrorAction SilentlyContinue -Force #Copy boot.WIM file to $Directory Copy-Item -Path ($Drive + ':\sources\boot.wim') -Destination $Directory -Force #Turn off read only Set-ItemProperty -Path ($Directory + '\boot.wim') -Name IsReadOnly -Value $false #Mount the WIM file Mount-WindowsImage -ImagePath ($Directory + '\boot.wim') -Index 1 -Path ($Directory + '\Mount') #Copy data folder to mounted image Copy-Item -Path ($Drive + ':\SMS\data') -Destination ($Directory + '\Mount\sms') -Recurse -Force #Unmount Windows Image Dismount-WindowsImage -Path ($Directory + '\Mount') -Save #Dismount disk image Dismount-DiskImage -ImagePath $File #Delete the old wim if it exists Remove-Item -Path ((Get-ChildItem -Path ($Directory + '\' + ((Get-ChildItem -path $File -ErrorAction SilentlyContinue).Basename) + '.wim')).FullName) -Force -ErrorAction SilentlyContinue #Rename boot.wim to match the basename of the ISO Rename-Item -Path ($Directory + '\boot.wim') -NewName ((Get-ChildItem -Path $File).BaseName + '.wim') -Force #Delete the Mount folder Remove-Item -Path ($Directory + '\Mount') -Recurse -Force -ErrorAction SilentlyContinue |
/image%2F0881799%2F20140610%2Fob_a8c7fe_logo2.jpg)
Commenter cet article