Function Remove-UpdateFromWIM{
[fusion_builder_container hundred_percent=“yes” overflow=“visible”][fusion_builder_row][fusion_builder_column type=“1_1” background_position=“left top” background_color=“” border_size=“” border_color=“” border_style=“solid” spacing=“yes” background_image=“” background_repeat=“no-repeat” padding=“” margin_top=“0px” margin_bottom=“0px” class=“” id=“” animation_type=“” animation_speed=“0.3” animation_direction=“left” hide_on_mobile=“no” center_content=“no” min_height=“none”][CmdletBinding()]
Param(
[Parameter(Mandatory=$true]
[ValidateScript({Test-Path $_ })]
$WIMFilePath,
[Parameter(Mandatory=$true)]$TemporaryMountFolderPath,
[Parameter(Mandatory=$true,valuefromPipeLine=$true)][string[]]$KbNameList
)
Begin{
}
Process{
write-verbose “Lauching DISM commands”
DISM /get-wiminfo /wimfile:$WimFilePath
while (!($IndexNumber)){
[Int]$IndexNumber = read-host -Prompt “Choose the index number corresponding to Operating System you want to work on:”
}
write-verbose “Lauching the remove operations”
DISM /mount-wim /wimfile:“$WIMFilePath” /Index:$indexNumber /MountDir:$TempMountDir
Write-host “Starting the remove process”
Foreach ($Kb in $KbNameList)
{
if ($kb -eq “”){
#Blank lines are skipped
continue
}
write-host “Removing $($kb) from $($wimfilePath)”
try {
#Removing the KB from mounted WimFile
DISM /image:$TemporaryMountFolderPath /remove-package /packagename:$KB
}
Catch{
write-warning $_
}
}
write-host “End Of file. Remove process completed.”
}
End{
write-verbose “Unmounting the WIM image”
DISM /unmount-wim /MountDir:$TemporaryMountFolderPath /discard
}
}
Leave A Comment