2023-03-07 14:28:00 -06:00
|
|
|
function Invoke-WinUtilTweaks {
|
|
|
|
<#
|
2023-10-19 17:12:55 -05:00
|
|
|
|
|
|
|
.SYNOPSIS
|
|
|
|
Invokes the function associated with each provided checkbox
|
|
|
|
|
|
|
|
.PARAMETER CheckBox
|
|
|
|
The checkbox to invoke
|
|
|
|
|
|
|
|
.PARAMETER undo
|
|
|
|
Indicates whether to undo the operation contained in the checkbox
|
|
|
|
|
2023-03-07 14:28:00 -06:00
|
|
|
#>
|
|
|
|
|
|
|
|
param(
|
|
|
|
$CheckBox,
|
|
|
|
$undo = $false
|
|
|
|
)
|
2024-01-15 11:32:19 -06:00
|
|
|
|
|
|
|
Write-Debug "Tweaks: $($CheckBox)"
|
2023-03-07 14:28:00 -06:00
|
|
|
if($undo){
|
|
|
|
$Values = @{
|
|
|
|
Registry = "OriginalValue"
|
|
|
|
ScheduledTask = "OriginalState"
|
|
|
|
Service = "OriginalType"
|
2023-07-13 15:46:00 -05:00
|
|
|
ScriptType = "UndoScript"
|
2023-03-07 14:28:00 -06:00
|
|
|
}
|
2023-07-13 15:46:00 -05:00
|
|
|
|
2023-10-19 17:12:55 -05:00
|
|
|
}
|
2023-03-07 14:28:00 -06:00
|
|
|
Else{
|
|
|
|
$Values = @{
|
|
|
|
Registry = "Value"
|
|
|
|
ScheduledTask = "State"
|
|
|
|
Service = "StartupType"
|
2023-07-13 15:46:00 -05:00
|
|
|
ScriptType = "InvokeScript"
|
2023-03-07 14:28:00 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if($sync.configs.tweaks.$CheckBox.ScheduledTask){
|
|
|
|
$sync.configs.tweaks.$CheckBox.ScheduledTask | ForEach-Object {
|
2024-01-15 11:32:19 -06:00
|
|
|
Write-Debug "$($psitem.Name) and state is $($psitem.$($values.ScheduledTask))"
|
2023-03-07 14:28:00 -06:00
|
|
|
Set-WinUtilScheduledTask -Name $psitem.Name -State $psitem.$($values.ScheduledTask)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($sync.configs.tweaks.$CheckBox.service){
|
|
|
|
$sync.configs.tweaks.$CheckBox.service | ForEach-Object {
|
2024-01-15 11:32:19 -06:00
|
|
|
Write-Debug "$($psitem.Name) and state is $($psitem.$($values.service))"
|
2023-03-07 14:28:00 -06:00
|
|
|
Set-WinUtilService -Name $psitem.Name -StartupType $psitem.$($values.Service)
|
|
|
|
}
|
|
|
|
}
|
2023-07-13 15:46:00 -05:00
|
|
|
if($sync.configs.tweaks.$CheckBox.registry){
|
|
|
|
$sync.configs.tweaks.$CheckBox.registry | ForEach-Object {
|
2024-01-15 11:32:19 -06:00
|
|
|
Write-Debug "$($psitem.Name) and state is $($psitem.$($values.registry))"
|
2023-07-13 15:46:00 -05:00
|
|
|
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 {
|
2024-01-15 11:32:19 -06:00
|
|
|
Write-Debug "$($psitem) and state is $($psitem.$($values.ScriptType))"
|
2023-07-13 15:46:00 -05:00
|
|
|
$Scriptblock = [scriptblock]::Create($psitem)
|
|
|
|
Invoke-WinUtilScript -ScriptBlock $scriptblock -Name $CheckBox
|
|
|
|
}
|
|
|
|
}
|
2023-03-07 14:28:00 -06:00
|
|
|
|
|
|
|
if(!$undo){
|
|
|
|
if($sync.configs.tweaks.$CheckBox.appx){
|
|
|
|
$sync.configs.tweaks.$CheckBox.appx | ForEach-Object {
|
2024-01-15 11:32:19 -06:00
|
|
|
Write-Debug "UNDO $($psitem.Name)"
|
2023-03-07 14:28:00 -06:00
|
|
|
Remove-WinUtilAPPX -Name $psitem
|
|
|
|
}
|
|
|
|
}
|
2023-07-13 15:46:00 -05:00
|
|
|
|
2023-03-07 14:28:00 -06:00
|
|
|
}
|
2023-07-13 15:46:00 -05:00
|
|
|
}
|