2021-08-03 20:17:31 +03:00
|
|
|
$windowsFeatures = (Get-ToolsetContent).windowsFeatures
|
2021-07-29 10:46:27 +03:00
|
|
|
|
2021-08-03 20:17:31 +03:00
|
|
|
foreach ($feature in $windowsFeatures) {
|
|
|
|
|
if ($feature.optionalFeature) {
|
|
|
|
|
Write-Host "Activating Windows Optional Feature '$($feature.name)'..."
|
|
|
|
|
Enable-WindowsOptionalFeature -Online -FeatureName $feature.name -NoRestart
|
2021-07-29 10:46:27 +03:00
|
|
|
|
2021-08-03 20:17:31 +03:00
|
|
|
$resultSuccess = $?
|
|
|
|
|
} else {
|
|
|
|
|
Write-Host "Activating Windows Feature '$($feature.name)'..."
|
|
|
|
|
$Arguments = @{
|
|
|
|
|
Name = $feature.name
|
|
|
|
|
IncludeAllSubFeature = [System.Convert]::ToBoolean($feature.includeAllSubFeatures)
|
|
|
|
|
IncludeManagementTools = [System.Convert]::ToBoolean($feature.includeManagementTools)
|
|
|
|
|
}
|
|
|
|
|
$result = Install-WindowsFeature @Arguments
|
2021-07-29 10:46:27 +03:00
|
|
|
|
2021-08-03 20:17:31 +03:00
|
|
|
$resultSuccess = $result.Success
|
|
|
|
|
}
|
2021-07-29 10:46:27 +03:00
|
|
|
|
2021-08-03 20:17:31 +03:00
|
|
|
if ($resultSuccess) {
|
|
|
|
|
Write-Host "Windows Feature '$($feature.name)' was activated successfully"
|
|
|
|
|
} else {
|
|
|
|
|
throw "Failed to activate Windows Feature '$($feature.name)'"
|
|
|
|
|
}
|
|
|
|
|
}
|