winutil/functions/private/Invoke-WinUtilCurrentSystem.ps1
Chris Titus 5dfa540c85
2023-09-13 September Bug fixes and Feature Additions (#1024)
* Add Message confirming restore point created (#953)

* Compile Winutil

* readme update

* Fix value for strings

* remove idm paid software

* add xdm

* add peazip

* Update winutil.ps1

* cleanup and tcpview addition

* fix choco wiztree

* Update tweaks.json

* Add CTT YouTube tutorial video to the README (#1007)

* Update edgeremoval.bat (#1009)

Update Edge Removal - AveYo to 2023.09.09

* Update README.md update docs

* Application Sort - DDU - Change in Runspace (#1013)

* Application list sorted alphabetically

* Indentation fix

* Compiled winutil.ps1

* Indentation fix

* Added Display Driver Uninstaller

* Fix apps falsely marked as installed #1015

* Fix new golang package

* music bee add #993

* Compile Winutil

* Cleanup Tweaks

* Compile Winutil

* OneDrive Removal Fix #385

* Compile Winutil

* Expand Common Issues in Readme

* one drive cleanup fixes

* Compile Winutil

* OneDrive Reinstall

* Compile Winutil

* Edge undo change

* Compile Winutil

* Revert "Merge branch 'test-2023-08-09' into 2023-09-07-Test"

This reverts commit 3636dcb4bb, reversing
changes made to db4f4925d2.

* rebase fix 1

* Musicbee

* uninstall fix

* Update README.md

* fix reinstalls on edge onedrive

* Update winutil.ps1

* Display tweak unpin icons

* Added tweaks for IPv6 (#1010)

* ipv6 merge

---------

Co-authored-by: Stephen Harris <stephen@lunamile.com>
Co-authored-by: ChrisTitusTech <ChrisTitusTech@users.noreply.github.com>
Co-authored-by: meenbeese <meenbeese@tutanota.com>
Co-authored-by: Christian S <crian84@gmail.com>
Co-authored-by: supplefrog <78985073+supplefrog@users.noreply.github.com>
Co-authored-by: Joan Solana Raduà <joansolana@proton.me>
2023-09-13 17:30:56 -05:00

103 lines
3.6 KiB
PowerShell

Function Invoke-WinUtilCurrentSystem {
<#
.DESCRIPTION
Function is meant to read existing system registry and check according configuration.
Example: Is telemetry enabled? check the box.
.EXAMPLE
Get-WinUtilCheckBoxes "WPFInstall"
#>
param(
$CheckBox
)
if ($checkbox -eq "winget"){
$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 ";")
if ($dependencies[-1] -in $sync.InstalledPrograms.Id) {
Write-Output $psitem.name
}
}
}
if($CheckBox -eq "tweaks"){
if(!(Test-Path 'HKU:\')){New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS}
$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
if($registryKeys -or $scheduledtaskKeys -or $serviceKeys){
$Values = @()
Foreach ($tweaks in $registryKeys){
Foreach($tweak in $tweaks){
if(test-path $tweak.Path){
$actualValue = Get-ItemProperty -Name $tweak.Name -Path $tweak.Path -ErrorAction SilentlyContinue | Select-Object -ExpandProperty $($tweak.Name)
$expectedValue = $tweak.Value
if ($expectedValue -notlike $actualValue){
$values += $False
}
}
}
}
Foreach ($tweaks in $scheduledtaskKeys){
Foreach($tweak in $tweaks){
$task = $ScheduledTasks | Where-Object {$($psitem.TaskPath + $psitem.TaskName) -like "\$($tweak.name)"}
if($task){
$actualValue = $task.State
$expectedValue = $tweak.State
if ($expectedValue -ne $actualValue){
$values += $False
}
}
}
}
Foreach ($tweaks in $serviceKeys){
Foreach($tweak in $tweaks){
$Service = Get-Service -Name $tweak.Name
if($Service){
$actualValue = $Service.StartType
$expectedValue = $tweak.StartupType
if ($expectedValue -ne $actualValue){
$values += $False
}
}
}
}
if($values -notcontains $false){
Write-Output $Config
}
}
}
}
}