Files
winutil/functions/private/Invoke-WinUtilTweaks.ps1
T

73 lines
2.3 KiB
PowerShell
Raw Normal View History

+3
2023-03-07 12:28:00 -08: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
+3
2023-03-07 12:28:00 -08:00
#>
param(
$CheckBox,
$undo = $false
)
2024-01-15 11:32:19 -06:00
Write-Debug "Tweaks: $($CheckBox)"
+3
2023-03-07 12:28:00 -08:00
if($undo){
$Values = @{
Registry = "OriginalValue"
ScheduledTask = "OriginalState"
Service = "OriginalType"
2023-07-13 15:46:00 -05:00
ScriptType = "UndoScript"
+3
2023-03-07 12:28:00 -08:00
}
2023-07-13 15:46:00 -05:00
2023-10-19 17:12:55 -05:00
}
+3
2023-03-07 12:28:00 -08:00
Else{
$Values = @{
Registry = "Value"
ScheduledTask = "State"
Service = "StartupType"
2023-07-13 15:46:00 -05:00
ScriptType = "InvokeScript"
+3
2023-03-07 12:28:00 -08: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))"
+3
2023-03-07 12:28:00 -08: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))"
+3
2023-03-07 12:28:00 -08: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
}
}
+3
2023-03-07 12:28:00 -08: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)"
+3
2023-03-07 12:28:00 -08:00
Remove-WinUtilAPPX -Name $psitem
}
}
2023-07-13 15:46:00 -05:00
+3
2023-03-07 12:28:00 -08:00
}
2023-07-13 15:46:00 -05:00
}