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 ) 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 } } } }