winutil/functions/private/Invoke-WinUtilTweaks.ps1
2023-10-04 10:08:10 -05:00

60 lines
1.8 KiB
PowerShell

function Invoke-WinUtilTweaks {
<#
.DESCRIPTION
This function converts all the values from the tweaks.json and routes them to the appropriate function
#>
param(
$CheckBox,
$undo = $false
)
if($undo){
$Values = @{
Registry = "OriginalValue"
ScheduledTask = "OriginalState"
Service = "OriginalType"
ScriptType = "UndoScript"
}
}
Else{
$Values = @{
Registry = "Value"
ScheduledTask = "State"
Service = "StartupType"
ScriptType = "InvokeScript"
}
}
if($sync.configs.tweaks.$CheckBox.ScheduledTask){
$sync.configs.tweaks.$CheckBox.ScheduledTask | ForEach-Object {
Set-WinUtilScheduledTask -Name $psitem.Name -State $psitem.$($values.ScheduledTask)
}
}
if($sync.configs.tweaks.$CheckBox.service){
$sync.configs.tweaks.$CheckBox.service | ForEach-Object {
Set-WinUtilService -Name $psitem.Name -StartupType $psitem.$($values.Service)
}
}
if($sync.configs.tweaks.$CheckBox.registry){
$sync.configs.tweaks.$CheckBox.registry | ForEach-Object {
Set-WinUtilRegistry -Name $psitem.Name -Path $psitem.Path -Type $psitem.Type -Value $psitem.$($values.registry)
}
}
if($sync.configs.tweaks.$CheckBox.$($values.ScriptType)){
$sync.configs.tweaks.$CheckBox.$($values.ScriptType) | ForEach-Object {
$Scriptblock = [scriptblock]::Create($psitem)
Invoke-WinUtilScript -ScriptBlock $scriptblock -Name $CheckBox
}
}
if(!$undo){
if($sync.configs.tweaks.$CheckBox.appx){
$sync.configs.tweaks.$CheckBox.appx | ForEach-Object {
Remove-WinUtilAPPX -Name $psitem
}
}
}
}