mirror of
https://github.com/ChrisTitusTech/winutil
synced 2026-06-05 06:37:26 +00:00
CleanUp Invoke-WinUtilFeatureInstall.ps1 and fix typo (#4481)
* CleanUp Invoke-WinUtilFeatureInstall.ps1 * Update Invoke-WinUtilFeatureInstall.ps1 * Update feature.json
This commit is contained in:
+1
-1
@@ -129,7 +129,7 @@
|
|||||||
"link": "https://winutil.christitus.com/dev/features/features/sandbox"
|
"link": "https://winutil.christitus.com/dev/features/features/sandbox"
|
||||||
},
|
},
|
||||||
"WPFFeatureInstall": {
|
"WPFFeatureInstall": {
|
||||||
"Content": "Run Features",
|
"Content": "Install Features",
|
||||||
"category": "Features",
|
"category": "Features",
|
||||||
"panel": "1",
|
"panel": "1",
|
||||||
"Type": "Button",
|
"Type": "Button",
|
||||||
|
|||||||
@@ -1,49 +1,16 @@
|
|||||||
function Invoke-WinUtilFeatureInstall {
|
function Invoke-WinUtilFeatureInstall ($CheckBox) {
|
||||||
<#
|
|
||||||
|
|
||||||
.SYNOPSIS
|
if ($sync.configs.feature.$CheckBox.feature) {
|
||||||
Converts all the values from the tweaks.json and routes them to the appropriate function
|
foreach ($feature in $sync.configs.feature.$CheckBox.feature) {
|
||||||
|
|
||||||
#>
|
|
||||||
|
|
||||||
param(
|
|
||||||
$CheckBox
|
|
||||||
)
|
|
||||||
|
|
||||||
if($sync.configs.feature.$CheckBox.feature) {
|
|
||||||
Foreach( $feature in $sync.configs.feature.$CheckBox.feature ) {
|
|
||||||
try {
|
|
||||||
Write-Host "Installing $feature"
|
Write-Host "Installing $feature"
|
||||||
Enable-WindowsOptionalFeature -Online -FeatureName $feature -All -NoRestart
|
Enable-WindowsOptionalFeature -Online -FeatureName $feature -All -NoRestart -ErrorAction Stop
|
||||||
} catch {
|
}
|
||||||
if ($CheckBox.Exception.Message -like "*requires elevation*") {
|
}
|
||||||
Write-Warning "Unable to Install $feature due to permissions. Are you running as admin?"
|
|
||||||
Invoke-WPFUIThread -ScriptBlock { Set-WinUtilTaskbaritem -state "Error" }
|
|
||||||
} else {
|
|
||||||
|
|
||||||
Write-Warning "Unable to Install $feature due to unhandled exception."
|
|
||||||
Write-Warning $CheckBox.Exception.StackTrace
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if($sync.configs.feature.$CheckBox.InvokeScript) {
|
|
||||||
Foreach( $script in $sync.configs.feature.$CheckBox.InvokeScript ) {
|
|
||||||
try {
|
|
||||||
$Scriptblock = [scriptblock]::Create($script)
|
|
||||||
|
|
||||||
|
if ($sync.configs.feature.$CheckBox.InvokeScript) {
|
||||||
|
foreach ($script in $sync.configs.feature.$CheckBox.InvokeScript) {
|
||||||
Write-Host "Running Script for $CheckBox"
|
Write-Host "Running Script for $CheckBox"
|
||||||
Invoke-Command $scriptblock -ErrorAction stop
|
Invoke-Command -ScriptBlock ([scriptblock]::Create($script)) -ErrorAction Stop
|
||||||
} catch {
|
|
||||||
if ($CheckBox.Exception.Message -like "*requires elevation*") {
|
|
||||||
Write-Warning "Unable to Install $feature due to permissions. Are you running as admin?"
|
|
||||||
Invoke-WPFUIThread -ScriptBlock { Set-WinUtilTaskbaritem -state "Error" }
|
|
||||||
} else {
|
|
||||||
Invoke-WPFUIThread -ScriptBlock { Set-WinUtilTaskbaritem -state "Error" }
|
|
||||||
Write-Warning "Unable to Install $feature due to unhandled exception."
|
|
||||||
Write-Warning $CheckBox.Exception.StackTrace
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user