function Invoke-WinUtilTweaks { <# .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 #> param( $CheckBox, $undo = $false ) Write-Debug "Tweaks: $($CheckBox)" 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 { Write-Debug "$($psitem.Name) and state is $($psitem.$($values.ScheduledTask))" Set-WinUtilScheduledTask -Name $psitem.Name -State $psitem.$($values.ScheduledTask) } } if($sync.configs.tweaks.$CheckBox.service){ $sync.configs.tweaks.$CheckBox.service | ForEach-Object { Write-Debug "$($psitem.Name) and state is $($psitem.$($values.service))" Set-WinUtilService -Name $psitem.Name -StartupType $psitem.$($values.Service) } } if($sync.configs.tweaks.$CheckBox.registry){ $sync.configs.tweaks.$CheckBox.registry | ForEach-Object { Write-Debug "$($psitem.Name) and state is $($psitem.$($values.registry))" 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 { Write-Debug "$($psitem) and state is $($psitem.$($values.ScriptType))" $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 { Write-Debug "UNDO $($psitem.Name)" Remove-WinUtilAPPX -Name $psitem } } } }