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

101 lines
3.6 KiB
PowerShell
Raw Normal View History

+2
2023-05-09 13:14:27 -05:00
Function Invoke-WinUtilCurrentSystem {
<#
2023-10-19 17:12:55 -05:00
.SYNOPSIS
Checks to see what tweaks have already been applied and what programs are installed, and checks the according boxes
+2
2023-05-09 13:14:27 -05:00
2023-10-19 17:12:55 -05:00
.EXAMPLE
+2
2023-05-09 13:14:27 -05:00
Get-WinUtilCheckBoxes "WPFInstall"
#>
param(
$CheckBox
)
if ($checkbox -eq "winget") {
+2
2023-05-09 13:14:27 -05:00
$originalEncoding = [Console]::OutputEncoding
[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new()
$Sync.InstalledPrograms = winget list -s winget | Select-Object -skip 3 | ConvertFrom-String -PropertyNames "Name", "Id", "Version", "Available" -Delimiter '\s{2,}'
[Console]::OutputEncoding = $originalEncoding
$filter = Get-WinUtilVariables -Type Checkbox | Where-Object {$psitem -like "WPFInstall*"}
$sync.GetEnumerator() | Where-Object {$psitem.Key -in $filter} | ForEach-Object {
$dependencies = @($sync.configs.applications.$($psitem.Key).winget -split ";")
2023-07-13 15:46:00 -05:00
if ($dependencies[-1] -in $sync.InstalledPrograms.Id) {
Write-Output $psitem.name
+2
2023-05-09 13:14:27 -05:00
}
}
}
if($CheckBox -eq "tweaks") {
+2
2023-05-09 13:14:27 -05:00
if(!(Test-Path 'HKU:\')) {New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS}
+2
2023-05-09 13:14:27 -05:00
$ScheduledTasks = Get-ScheduledTask
$sync.configs.tweaks | Get-Member -MemberType NoteProperty | ForEach-Object {
$Config = $psitem.Name
#WPFEssTweaksTele
$registryKeys = $sync.configs.tweaks.$Config.registry
$scheduledtaskKeys = $sync.configs.tweaks.$Config.scheduledtask
$serviceKeys = $sync.configs.tweaks.$Config.service
2023-10-19 17:12:55 -05:00
if($registryKeys -or $scheduledtaskKeys -or $serviceKeys) {
+2
2023-05-09 13:14:27 -05:00
$Values = @()
Foreach ($tweaks in $registryKeys) {
Foreach($tweak in $tweaks) {
2023-10-19 17:12:55 -05:00
if(test-path $tweak.Path) {
+2
2023-05-09 13:14:27 -05:00
$actualValue = Get-ItemProperty -Name $tweak.Name -Path $tweak.Path -ErrorAction SilentlyContinue | Select-Object -ExpandProperty $($tweak.Name)
$expectedValue = $tweak.Value
if ($expectedValue -notlike $actualValue) {
2023-10-19 17:12:55 -05:00
$values += $False
+2
2023-05-09 13:14:27 -05:00
}
} else {
$values += $False
}
+2
2023-05-09 13:14:27 -05:00
}
}
Foreach ($tweaks in $scheduledtaskKeys) {
Foreach($tweak in $tweaks) {
+2
2023-05-09 13:14:27 -05:00
$task = $ScheduledTasks | Where-Object {$($psitem.TaskPath + $psitem.TaskName) -like "\$($tweak.name)"}
2023-10-19 17:12:55 -05:00
if($task) {
+2
2023-05-09 13:14:27 -05:00
$actualValue = $task.State
$expectedValue = $tweak.State
if ($expectedValue -ne $actualValue) {
+2
2023-05-09 13:14:27 -05:00
$values += $False
}
}
}
}
Foreach ($tweaks in $serviceKeys) {
Foreach($tweak in $tweaks) {
+2
2023-05-09 13:14:27 -05:00
$Service = Get-Service -Name $tweak.Name
2023-10-19 17:12:55 -05:00
if($Service) {
+2
2023-05-09 13:14:27 -05:00
$actualValue = $Service.StartType
$expectedValue = $tweak.StartupType
if ($expectedValue -ne $actualValue) {
+2
2023-05-09 13:14:27 -05:00
$values += $False
}
}
}
}
if($values -notcontains $false) {
+2
2023-05-09 13:14:27 -05:00
Write-Output $Config
}
}
}
}
}