2023-05-09 13:14:27 -05:00
|
|
|
function Invoke-WinUtilFeatureInstall {
|
|
|
|
<#
|
2023-10-19 17:12:55 -05:00
|
|
|
|
|
|
|
.SYNOPSIS
|
|
|
|
Converts all the values from the tweaks.json and routes them to the appropriate function
|
|
|
|
|
2023-05-09 13:14:27 -05:00
|
|
|
#>
|
|
|
|
|
|
|
|
param(
|
|
|
|
$CheckBox
|
|
|
|
)
|
|
|
|
|
|
|
|
$CheckBox | ForEach-Object {
|
|
|
|
if($sync.configs.feature.$psitem.feature){
|
|
|
|
Foreach( $feature in $sync.configs.feature.$psitem.feature ){
|
2023-10-19 17:12:55 -05:00
|
|
|
Try{
|
2023-05-09 13:14:27 -05:00
|
|
|
Write-Host "Installing $feature"
|
|
|
|
Enable-WindowsOptionalFeature -Online -FeatureName $feature -All -NoRestart
|
|
|
|
}
|
|
|
|
Catch{
|
|
|
|
if ($psitem.Exception.Message -like "*requires elevation*"){
|
|
|
|
Write-Warning "Unable to Install $feature due to permissions. Are you running as admin?"
|
|
|
|
}
|
|
|
|
|
|
|
|
else{
|
|
|
|
Write-Warning "Unable to Install $feature due to unhandled exception"
|
2023-10-19 17:12:55 -05:00
|
|
|
Write-Warning $psitem.Exception.StackTrace
|
2023-05-09 13:14:27 -05:00
|
|
|
}
|
|
|
|
}
|
2023-10-19 17:12:55 -05:00
|
|
|
}
|
2023-05-09 13:14:27 -05:00
|
|
|
}
|
|
|
|
if($sync.configs.feature.$psitem.InvokeScript){
|
|
|
|
Foreach( $script in $sync.configs.feature.$psitem.InvokeScript ){
|
|
|
|
Try{
|
|
|
|
$Scriptblock = [scriptblock]::Create($script)
|
|
|
|
|
|
|
|
Write-Host "Running Script for $psitem"
|
|
|
|
Invoke-Command $scriptblock -ErrorAction stop
|
|
|
|
}
|
|
|
|
Catch{
|
|
|
|
if ($psitem.Exception.Message -like "*requires elevation*"){
|
|
|
|
Write-Warning "Unable to Install $feature due to permissions. Are you running as admin?"
|
|
|
|
}
|
|
|
|
|
|
|
|
else{
|
|
|
|
Write-Warning "Unable to Install $feature due to unhandled exception"
|
2023-10-19 17:12:55 -05:00
|
|
|
Write-Warning $psitem.Exception.StackTrace
|
2023-05-09 13:14:27 -05:00
|
|
|
}
|
|
|
|
}
|
2023-10-19 17:12:55 -05:00
|
|
|
}
|
2023-05-09 13:14:27 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|