mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-11-14 14:45:52 -06:00
e0889d51db
* move Microwin related stuff to own Folder under "Functions" * update runspace function gathering logic * update Recall logic (from main repo) * change to easier naming scheme - rename files - rename function names * remove unneeded comment (after @CodingWonders's suggestion)
41 lines
1.8 KiB
PowerShell
41 lines
1.8 KiB
PowerShell
function Microwin-RemoveFeatures() {
|
|
<#
|
|
.SYNOPSIS
|
|
Removes certain features from ISO image
|
|
|
|
.PARAMETER Name
|
|
No Params
|
|
|
|
.EXAMPLE
|
|
Microwin-RemoveFeatures
|
|
#>
|
|
try {
|
|
$featlist = (Get-WindowsOptionalFeature -Path $scratchDir)
|
|
|
|
$featlist = $featlist | Where-Object {
|
|
$_.FeatureName -NotLike "*Defender*" -AND
|
|
$_.FeatureName -NotLike "*Printing*" -AND
|
|
$_.FeatureName -NotLike "*TelnetClient*" -AND
|
|
$_.FeatureName -NotLike "*PowerShell*" -AND
|
|
$_.FeatureName -NotLike "*NetFx*" -AND
|
|
$_.FeatureName -NotLike "*Media*" -AND
|
|
$_.FeatureName -NotLike "*NFS*" -AND
|
|
$_.FeatureName -NotLike "*SearchEngine*" -AND
|
|
$_.FeatureName -NotLike "*RemoteDesktop*" -AND
|
|
$_.State -ne "Disabled"
|
|
}
|
|
|
|
foreach($feature in $featlist) {
|
|
$status = "Removing feature $($feature.FeatureName)"
|
|
Write-Progress -Activity "Removing features" -Status $status -PercentComplete ($counter++/$featlist.Count*100)
|
|
Write-Debug "Removing feature $($feature.FeatureName)"
|
|
Disable-WindowsOptionalFeature -Path "$scratchDir" -FeatureName $($feature.FeatureName) -Remove -ErrorAction SilentlyContinue -NoRestart
|
|
}
|
|
Write-Progress -Activity "Removing features" -Status "Ready" -Completed
|
|
Write-Host "You can re-enable the disabled features at any time, using either Windows Update or the SxS folder in <installation media>\Sources."
|
|
} catch {
|
|
Write-Host "Unable to get information about the features. MicroWin processing will continue, but features will not be processed"
|
|
Write-Host "Error information: $($_.Exception.Message)" -ForegroundColor Yellow
|
|
}
|
|
}
|