2023-12-04 10:50:53 +01:00
|
|
|
####################################################################################
|
|
|
|
|
## File: Install-WindowsFeatures.ps1
|
|
|
|
|
## Desc: Install Windows Features
|
|
|
|
|
####################################################################################
|
|
|
|
|
|
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)'..."
|
2023-12-11 22:23:36 +01:00
|
|
|
$arguments = @{
|
|
|
|
|
Name = $feature.name
|
|
|
|
|
IncludeAllSubFeature = [System.Convert]::ToBoolean($feature.includeAllSubFeatures)
|
2021-08-03 20:17:31 +03:00
|
|
|
IncludeManagementTools = [System.Convert]::ToBoolean($feature.includeManagementTools)
|
|
|
|
|
}
|
2023-12-11 22:23:36 +01:00
|
|
|
$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)'"
|
|
|
|
|
}
|
2023-04-06 12:38:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# it improves Android emulator launch on Windows Server
|
|
|
|
|
# https://learn.microsoft.com/en-us/windows-server/virtualization/hyper-v/manage/manage-hyper-v-scheduler-types
|
|
|
|
|
bcdedit /set hypervisorschedulertype root
|
2023-12-11 22:23:36 +01:00
|
|
|
if ($LASTEXITCODE -ne 0) {
|
|
|
|
|
throw "Failed to set hypervisorschedulertype to root"
|
|
|
|
|
}
|