mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-06-28 00:54:47 -05:00
Test 12 2022 - Big Foundational Update (#637)
* Fix of the unit tests (#468) * fix pester tests * fix function (#467) * Cherry pick and fix helper script * remove admin check and disable * Trim Trailing Whitespace (#472) Co-authored-by: Chris Titus <contact@christitus.com> * Better .gitignore (#473) * add progress and add wait to start-process (#475) * Fixed Cloudflare Naming (#504) * Update winutil.ps1 * Update MainWindow.xaml * Update check for Chocolatey (#520) * Update winutil.ps1 * Update check for Chocolatey Let user decide if he wants to install Chocolatey * Update winutil.ps1 (#525) Migrate to Switch-Tab function * Update winutil.ps1 (#531) Changes to "DiagTrack" service. * add responsive winget installs (#540) * add responsive winget installs * Update winutil.ps1 fix typo * remove no longer used paramater * add golang, an installation option in development list (#542) * Updated winget functions (#543) * update functions * Update winutil.ps1 forgot triple quotes * Update winutil.ps1 fixed vscode using wrong double quotes * Functions and error handling (#552) * move winget install to function and exception * updated winget upgrade to new install process * add logging to update * choco to function and write-output to ensure logs * update error handling * revert write-host and add invoke-runspace * Added runspace to load configs in background * fix unit tests * update pester tests * update pester * update pester * update pester * updated tweaks config to use WPF variable name * Fix data type of MouseHoverTime (#568) Setting Computer\HKEY_CURRENT_USER\Control Panel\Mouse\MouseHoverTime needs to be REG_SZ instead of REG_DWORD. With the wrong type the Taskbar and the Start Menu become hard to use because everything pops up instantly, probably because it's then treated as a 0 ms delay. * fix restore launch to quick access & OOSU10 download (#565) * Fix grammar (#577) * Update MainWindow.xaml * Update MainWindow-runspace.xaml * fix enable numlock after startup (#580) * Update README.md (#616) Added DNS provider into readme * Fix O&O ShutUp10 disabling app notifications and hide search box (#630) * Add files via upload Added ooshutup10_winutil_settings and fix the issue where OOSU10 disable app notifications and hide search box in windows. * Update winutil.ps1 Change ooshut10.cfg to ooshutup10_winutil_settings.cfg and fix the issues in https://github.com/ChrisTitusTech/winutil/issues/629 Now when apply the tweaks by O&O ShutUp10, will keep search box and notifications will not be disabled. * Update winutil.ps1 * Update winutil.ps1 --------- Co-authored-by: Chris Titus <contact@christitus.com> * Create ooshutup10_winutil_settings.cfg * Feature/tweakstofunctions (#576) * add functions for services * Move WPFEssTweaksDVR to function * Add invoke script and moved temp files * WPFEssTweaksHiber and formatting * WPFEssTweaksHiber * WPFEssTweaksHome and service * WPFEssTweaksLoc * TPMCheck * WPFEssTweaksDiskCleanup * Add error handling for invoke script * grammer * UAC and tweaks * WPFMiscTweaksDisableNotifications * WPFMiscTweaksRightClickMenu * Added DNS configuration + Reset to DHCP * WPFEssTweaksOO * WPFEssTweaksRP * WPFEssTweaksServices * WPFEssTweaksStorage * WPFEssTweaksTele * WPFEssTweaksWifi * WPFMiscTweaksLapPower * WPFMiscTweaksLapNum * WPFMiscTweaksPower * WPFMiscTweaksNum * WPFMiscTweaksExt * WPFMiscTweaksUTC * WPFMiscTweaksDisplay * Mouse Acceleration * WPFEssTweaksRemoveCortana * WPFEssTweaksDeBloat * set teaks to get checkboxes and loop * remove isdev * add help documentation * Add Quad 9 for #532 and #416 * remove isdev * Update tweaks.json Remove-ItemProperty is no longer needed as this was a bug from a bad commit 4 months ago. --------- Co-authored-by: Chris Titus <contact@christitus.com> * Tweak bingsearch (#620) * add functions for services * Move WPFEssTweaksDVR to function * Add invoke script and moved temp files * WPFEssTweaksHiber and formatting * WPFEssTweaksHiber * WPFEssTweaksHome and service * WPFEssTweaksLoc * TPMCheck * WPFEssTweaksDiskCleanup * Add error handling for invoke script * grammer * UAC and tweaks * WPFMiscTweaksDisableNotifications * WPFMiscTweaksRightClickMenu * Added DNS configuration + Reset to DHCP * WPFEssTweaksOO * WPFEssTweaksRP * WPFEssTweaksServices * WPFEssTweaksStorage * WPFEssTweaksTele * WPFEssTweaksWifi * WPFMiscTweaksLapPower * WPFMiscTweaksLapNum * WPFMiscTweaksPower * WPFMiscTweaksNum * WPFMiscTweaksExt * WPFMiscTweaksUTC * WPFMiscTweaksDisplay * Mouse Acceleration * WPFEssTweaksRemoveCortana * WPFEssTweaksDeBloat * set teaks to get checkboxes and loop * remove isdev * add help documentation * Add Quad 9 for #532 and #416 * remove isdev * Update helper script and add tweak * update changes * Refactor/runspaces (#626) * modify runspace.ps1 to compile * update compiler to include warning * unit test * implement invoke-button and naming standard * naming standard * fix winutil tests * update functions * add version number * fix codeowners * fix import * undo tweaks now pull from config * pester test * Compile Winutil * python and oo cfg -fix python 3 to 3.11 -fix o&o shutup cfg -enable dev mode for testing * Force install missing winget Fix method for winget install on any system. * Deluge Addition * Feature/impex (#619) * add functions for services * Move WPFEssTweaksDVR to function * Add invoke script and moved temp files * WPFEssTweaksHiber and formatting * WPFEssTweaksHiber * WPFEssTweaksHome and service * WPFEssTweaksLoc * TPMCheck * WPFEssTweaksDiskCleanup * Add error handling for invoke script * grammer * UAC and tweaks * WPFMiscTweaksDisableNotifications * WPFMiscTweaksRightClickMenu * Added DNS configuration + Reset to DHCP * WPFEssTweaksOO * WPFEssTweaksRP * WPFEssTweaksServices * WPFEssTweaksStorage * WPFEssTweaksTele * WPFEssTweaksWifi * WPFMiscTweaksLapPower * WPFMiscTweaksLapNum * WPFMiscTweaksPower * WPFMiscTweaksNum * WPFMiscTweaksExt * WPFMiscTweaksUTC * WPFMiscTweaksDisplay * Mouse Acceleration * WPFEssTweaksRemoveCortana * WPFEssTweaksDeBloat * set teaks to get checkboxes and loop * remove isdev * add help documentation * Add Quad 9 for #532 and #416 * remove isdev * Working Import and Export * Add null check * Remove IsDev * sync with test * redo impex * Irm runspace fix (#635) * Update runspace.ps1 * Update start.ps1 * compiled for testing * Compile Winutil * Compile Winutil * test * disable runspace build * test * change compile to ascii * change compile to winutil * Compile Winutil * Delete MainWindow.xaml * Update release.yaml runspace merge job * remove update branch --------- Co-authored-by: DeveloperDurp <developerdurp@durp.info> Co-authored-by: Carter <60557606+Carterpersall@users.noreply.github.com> Co-authored-by: Jacobtread <33708767+jacobtread@users.noreply.github.com> Co-authored-by: jstok84 <jstok84@gmail.com> Co-authored-by: WolfBungalow <irtwit@gmail.com> Co-authored-by: Ankit Yadav <52023083+4nkitd@users.noreply.github.com> Co-authored-by: Starfiresg1 <Starfiresg1@users.noreply.github.com> Co-authored-by: Adrián Insaurralde Avalos <36372335+adrianinsaval@users.noreply.github.com> Co-authored-by: Hyperio <96462198+hyperio546@users.noreply.github.com> Co-authored-by: dennyamarojr <36896116+dennyamarojr@users.noreply.github.com> Co-authored-by: ChrisTitusTech <ChrisTitusTech@users.noreply.github.com>
This commit is contained in:
52
functions/private/Get-WinUtilCheckBoxes.ps1
Normal file
52
functions/private/Get-WinUtilCheckBoxes.ps1
Normal file
@ -0,0 +1,52 @@
|
||||
Function Get-WinUtilCheckBoxes {
|
||||
|
||||
<#
|
||||
|
||||
.DESCRIPTION
|
||||
Function is meant to find all checkboxes that are checked on the specefic tab and input them into a script.
|
||||
|
||||
Outputed data will be the names of the checkboxes that were checked
|
||||
|
||||
.EXAMPLE
|
||||
|
||||
Get-WinUtilCheckBoxes "WPFInstall"
|
||||
|
||||
#>
|
||||
|
||||
Param(
|
||||
$Group,
|
||||
[boolean]$unCheck = $true
|
||||
)
|
||||
|
||||
|
||||
$Output = New-Object System.Collections.Generic.List[System.Object]
|
||||
|
||||
if($Group -eq "WPFInstall"){
|
||||
$CheckBoxes = get-variable | Where-Object {$psitem.name -like "WPFInstall*" -and $psitem.value.GetType().name -eq "CheckBox"}
|
||||
Foreach ($CheckBox in $CheckBoxes){
|
||||
if($CheckBox.value.ischecked -eq $true){
|
||||
$sync.configs.applications.$($CheckBox.name).winget -split ";" | ForEach-Object {
|
||||
$Output.Add($psitem)
|
||||
}
|
||||
if ($uncheck -eq $true){
|
||||
$CheckBox.value.ischecked = $false
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if($Group -eq "WPFTweaks"){
|
||||
$CheckBoxes = get-variable | Where-Object {$psitem.name -like "WPF*Tweaks*" -and $psitem.value.GetType().name -eq "CheckBox"}
|
||||
Foreach ($CheckBox in $CheckBoxes){
|
||||
if($CheckBox.value.ischecked -eq $true){
|
||||
$Output.Add($Checkbox.Name)
|
||||
|
||||
if ($uncheck -eq $true){
|
||||
$CheckBox.value.ischecked = $false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write-Output $($Output | Select-Object -Unique)
|
||||
}
|
16
functions/private/Get-WinUtilDarkMode.ps1
Normal file
16
functions/private/Get-WinUtilDarkMode.ps1
Normal file
@ -0,0 +1,16 @@
|
||||
Function Get-WinUtilDarkMode {
|
||||
<#
|
||||
|
||||
.DESCRIPTION
|
||||
Meant to pull the registry keys responsible for Dark Mode and returns true or false
|
||||
|
||||
#>
|
||||
$app = (Get-ItemProperty -path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize').AppsUseLightTheme
|
||||
$system = (Get-ItemProperty -path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize').SystemUsesLightTheme
|
||||
if($app -eq 0 -and $system -eq 0){
|
||||
return $true
|
||||
}
|
||||
else{
|
||||
return $false
|
||||
}
|
||||
}
|
18
functions/private/Get-WinUtilInstallerProcess.ps1
Normal file
18
functions/private/Get-WinUtilInstallerProcess.ps1
Normal file
@ -0,0 +1,18 @@
|
||||
function Get-WinUtilInstallerProcess {
|
||||
<#
|
||||
|
||||
.DESCRIPTION
|
||||
Meant to check for running processes and will return a boolean response
|
||||
|
||||
#>
|
||||
|
||||
param($Process)
|
||||
|
||||
if ($Null -eq $Process){
|
||||
return $false
|
||||
}
|
||||
if (Get-Process -Id $Process.Id -ErrorAction SilentlyContinue){
|
||||
return $true
|
||||
}
|
||||
return $false
|
||||
}
|
30
functions/private/Install-WinUtilChoco.ps1
Normal file
30
functions/private/Install-WinUtilChoco.ps1
Normal file
@ -0,0 +1,30 @@
|
||||
function Install-WinUtilChoco {
|
||||
|
||||
<#
|
||||
|
||||
.DESCRIPTION
|
||||
Function is meant to ensure Choco is installed
|
||||
|
||||
#>
|
||||
|
||||
try{
|
||||
Write-Host "Checking if Chocolatey is Installed..."
|
||||
|
||||
if((Test-WinUtilPackageManager -choco)){
|
||||
Write-Host "Chocolatey Already Installed"
|
||||
return
|
||||
}
|
||||
|
||||
Write-Host "Seems Chocolatey is not installed, installing now?"
|
||||
#Let user decide if he wants to install Chocolatey
|
||||
$confirmation = Read-Host "Are you Sure You Want To Proceed:(y/n)"
|
||||
if ($confirmation -eq 'y') {
|
||||
Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) -ErrorAction Stop
|
||||
powershell choco feature enable -n allowGlobalConfirmation
|
||||
}
|
||||
}
|
||||
Catch{
|
||||
throw [ChocoFailedInstall]::new('Failed to install')
|
||||
}
|
||||
|
||||
}
|
28
functions/private/Install-WinUtilProgramWinget.ps1
Normal file
28
functions/private/Install-WinUtilProgramWinget.ps1
Normal file
@ -0,0 +1,28 @@
|
||||
Function Install-WinUtilProgramWinget {
|
||||
|
||||
<#
|
||||
|
||||
.DESCRIPTION
|
||||
This will install programs via Winget using a new powershell.exe instance to prevent the GUI from locking up.
|
||||
|
||||
Note the triple quotes are required any time you need a " in a normal script block.
|
||||
|
||||
#>
|
||||
|
||||
param($ProgramsToInstall)
|
||||
|
||||
$x = 0
|
||||
$count = $($ProgramsToInstall -split ",").Count
|
||||
|
||||
Write-Progress -Activity "Installing Applications" -Status "Starting" -PercentComplete 0
|
||||
|
||||
Foreach ($Program in $($ProgramsToInstall -split ",")){
|
||||
|
||||
Write-Progress -Activity "Installing Applications" -Status "Installing $Program $($x + 1) of $count" -PercentComplete $($x/$count*100)
|
||||
Start-Process -FilePath winget -ArgumentList "install -e --accept-source-agreements --accept-package-agreements --silent $Program" -NoNewWindow -Wait;
|
||||
$X++
|
||||
}
|
||||
|
||||
Write-Progress -Activity "Installing Applications" -Status "Finished" -Completed
|
||||
|
||||
}
|
68
functions/private/Install-WinUtilWinget.ps1
Normal file
68
functions/private/Install-WinUtilWinget.ps1
Normal file
@ -0,0 +1,68 @@
|
||||
function Install-WinUtilWinget {
|
||||
|
||||
<#
|
||||
|
||||
.DESCRIPTION
|
||||
Function is meant to ensure winget is installed
|
||||
|
||||
#>
|
||||
Try{
|
||||
Write-Host "Checking if Winget is Installed..."
|
||||
if (Test-WinUtilPackageManager -winget) {
|
||||
#Checks if winget executable exists and if the Windows Version is 1809 or higher
|
||||
Write-Host "Winget Already Installed"
|
||||
return
|
||||
}
|
||||
|
||||
#Gets the computer's information
|
||||
if ($null -eq $sync.ComputerInfo){
|
||||
$ComputerInfo = Get-ComputerInfo -ErrorAction Stop
|
||||
}
|
||||
Else {
|
||||
$ComputerInfo = $sync.ComputerInfo
|
||||
}
|
||||
|
||||
if (($ComputerInfo.WindowsVersion) -lt "1809") {
|
||||
#Checks if Windows Version is too old for winget
|
||||
Write-Host "Winget is not supported on this version of Windows (Pre-1809)"
|
||||
return
|
||||
}
|
||||
|
||||
#Gets the Windows Edition
|
||||
$OSName = if ($ComputerInfo.OSName) {
|
||||
$ComputerInfo.OSName
|
||||
}else {
|
||||
$ComputerInfo.WindowsProductName
|
||||
}
|
||||
|
||||
if (((($OSName.IndexOf("LTSC")) -ne -1) -or ($OSName.IndexOf("Server") -ne -1)) -and (($ComputerInfo.WindowsVersion) -ge "1809")) {
|
||||
|
||||
Write-Host "Running Alternative Installer for LTSC/Server Editions"
|
||||
|
||||
# Switching to winget-install from PSGallery from asheroto
|
||||
# Source: https://github.com/asheroto/winget-installer
|
||||
|
||||
Start-Process powershell.exe -Verb RunAs -ArgumentList "-command irm https://raw.githubusercontent.com/ChrisTitusTech/winutil/$BranchToUse/winget.ps1 | iex | Out-Host" -WindowStyle Normal -ErrorAction Stop
|
||||
|
||||
if(!(Test-WinUtilPackageManager -winget)){
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
#Installing Winget from the Microsoft Store
|
||||
Write-Host "Winget not found, installing it now."
|
||||
Start-Process "ms-appinstaller:?source=https://aka.ms/getwinget"
|
||||
$nid = (Get-Process AppInstaller).Id
|
||||
Wait-Process -Id $nid
|
||||
|
||||
if(!(Test-WinUtilPackageManager -winget)){
|
||||
break
|
||||
}
|
||||
}
|
||||
Write-Host "Winget Installed"
|
||||
}
|
||||
Catch{
|
||||
throw [WingetFailedInstall]::new('Failed to install')
|
||||
}
|
||||
}
|
26
functions/private/Invoke-WinUtilScript.ps1
Normal file
26
functions/private/Invoke-WinUtilScript.ps1
Normal file
@ -0,0 +1,26 @@
|
||||
function Invoke-WinUtilScript {
|
||||
<#
|
||||
|
||||
.DESCRIPTION
|
||||
This function will run a seperate powershell script. Meant for things that can't be handled with the other functions
|
||||
|
||||
.EXAMPLE
|
||||
|
||||
$Scriptblock = [scriptblock]::Create({"Write-output 'Hello World'"})
|
||||
Invoke-WinUtilScript -ScriptBlock $scriptblock -Name "Hello World"
|
||||
|
||||
#>
|
||||
param (
|
||||
$Name,
|
||||
[scriptblock]$scriptblock
|
||||
)
|
||||
|
||||
Try{
|
||||
Invoke-Command $scriptblock -ErrorAction stop
|
||||
Write-Host "Running Script for $name"
|
||||
}
|
||||
Catch{
|
||||
Write-Warning "Unable to run script for $name due to unhandled exception"
|
||||
Write-Warning $psitem.Exception.StackTrace
|
||||
}
|
||||
}
|
57
functions/private/Invoke-WinUtilTweaks.ps1
Normal file
57
functions/private/Invoke-WinUtilTweaks.ps1
Normal file
@ -0,0 +1,57 @@
|
||||
function Invoke-WinUtilTweaks {
|
||||
<#
|
||||
|
||||
.DESCRIPTION
|
||||
This function converts all the values from the tweaks.json and routes them to the appropriate function
|
||||
|
||||
#>
|
||||
|
||||
param(
|
||||
$CheckBox,
|
||||
$undo = $false
|
||||
)
|
||||
if($undo){
|
||||
$Values = @{
|
||||
Registry = "OriginalValue"
|
||||
ScheduledTask = "OriginalState"
|
||||
Service = "OriginalType"
|
||||
}
|
||||
}
|
||||
Else{
|
||||
$Values = @{
|
||||
Registry = "Value"
|
||||
ScheduledTask = "State"
|
||||
Service = "StartupType"
|
||||
}
|
||||
}
|
||||
|
||||
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.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(!$undo){
|
||||
if($sync.configs.tweaks.$CheckBox.appx){
|
||||
$sync.configs.tweaks.$CheckBox.appx | ForEach-Object {
|
||||
Remove-WinUtilAPPX -Name $psitem
|
||||
}
|
||||
}
|
||||
if($sync.configs.tweaks.$CheckBox.InvokeScript){
|
||||
$sync.configs.tweaks.$CheckBox.InvokeScript | ForEach-Object {
|
||||
$Scriptblock = [scriptblock]::Create($psitem)
|
||||
Invoke-WinUtilScript -ScriptBlock $scriptblock -Name $CheckBox
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
34
functions/private/Remove-WinUtilAPPX.ps1
Normal file
34
functions/private/Remove-WinUtilAPPX.ps1
Normal file
@ -0,0 +1,34 @@
|
||||
function Remove-WinUtilAPPX {
|
||||
<#
|
||||
|
||||
.DESCRIPTION
|
||||
This function will remove any of the provided APPX names
|
||||
|
||||
.EXAMPLE
|
||||
|
||||
Remove-WinUtilAPPX -Name "Microsoft.Microsoft3DViewer"
|
||||
|
||||
#>
|
||||
param (
|
||||
$Name
|
||||
)
|
||||
|
||||
Try{
|
||||
Write-Host "Removing $Name"
|
||||
Get-AppxPackage "*$Name*" | Remove-AppxPackage -ErrorAction SilentlyContinue
|
||||
Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like "*$Name*" | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue
|
||||
}
|
||||
Catch [System.Exception] {
|
||||
if($psitem.Exception.Message -like "*The requested operation requires elevation*"){
|
||||
Write-Warning "Unable to uninstall $name due to a Security Exception"
|
||||
}
|
||||
Else{
|
||||
Write-Warning "Unable to uninstall $name due to unhandled exception"
|
||||
Write-Warning $psitem.Exception.StackTrace
|
||||
}
|
||||
}
|
||||
Catch{
|
||||
Write-Warning "Unable to uninstall $name due to unhandled exception"
|
||||
Write-Warning $psitem.Exception.StackTrace
|
||||
}
|
||||
}
|
32
functions/private/Set-WinUtilDNS.ps1
Normal file
32
functions/private/Set-WinUtilDNS.ps1
Normal file
@ -0,0 +1,32 @@
|
||||
function Set-WinUtilDNS {
|
||||
<#
|
||||
|
||||
.DESCRIPTION
|
||||
This function will set the DNS of all interfaces that are in the "Up" state. It will lookup the values from the DNS.Json file
|
||||
|
||||
.EXAMPLE
|
||||
|
||||
Set-WinUtilDNS -DNSProvider "google"
|
||||
|
||||
#>
|
||||
param($DNSProvider)
|
||||
if($DNSProvider -eq "Default"){return}
|
||||
Try{
|
||||
$Adapters = Get-NetAdapter | Where-Object {$_.Status -eq "Up"}
|
||||
Write-Host "Ensuring DNS is set to $DNSProvider on the following interfaces"
|
||||
Write-Host $($Adapters | Out-String)
|
||||
|
||||
Foreach ($Adapter in $Adapters){
|
||||
if($DNSProvider -eq "DHCP"){
|
||||
Set-DnsClientServerAddress -InterfaceIndex $Adapter.ifIndex -ResetServerAddresses
|
||||
}
|
||||
Else{
|
||||
Set-DnsClientServerAddress -InterfaceIndex $Adapter.ifIndex -ServerAddresses ("$($sync.configs.dns.$DNSProvider.Primary)", "$($sync.configs.dns.$DNSProvider.Secondary)")
|
||||
}
|
||||
}
|
||||
}
|
||||
Catch{
|
||||
Write-Warning "Unable to set DNS Provider due to an unhandled exception"
|
||||
Write-Warning $psitem.Exception.StackTrace
|
||||
}
|
||||
}
|
40
functions/private/Set-WinUtilRegistry.ps1
Normal file
40
functions/private/Set-WinUtilRegistry.ps1
Normal file
@ -0,0 +1,40 @@
|
||||
function Set-WinUtilRegistry {
|
||||
<#
|
||||
|
||||
.DESCRIPTION
|
||||
This function will make all modifications to the registry
|
||||
|
||||
.EXAMPLE
|
||||
|
||||
Set-WinUtilRegistry -Name "PublishUserActivities" -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Type "DWord" -Value "0"
|
||||
|
||||
#>
|
||||
param (
|
||||
$Name,
|
||||
$Path,
|
||||
$Type,
|
||||
$Value
|
||||
)
|
||||
|
||||
Try{
|
||||
if(!(Test-Path 'HKU:\')){New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS}
|
||||
|
||||
If (!(Test-Path $Path)) {
|
||||
Write-Host "$Path was not found, Creating..."
|
||||
New-Item -Path $Path -Force -ErrorAction Stop | Out-Null
|
||||
}
|
||||
|
||||
Write-Host "Set $Path\$Name to $Value"
|
||||
Set-ItemProperty -Path $Path -Name $Name -Type $Type -Value $Value -Force -ErrorAction Stop | Out-Null
|
||||
}
|
||||
Catch [System.Security.SecurityException] {
|
||||
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
|
||||
}
|
||||
Catch [System.Management.Automation.ItemNotFoundException] {
|
||||
Write-Warning $psitem.Exception.ErrorRecord
|
||||
}
|
||||
Catch{
|
||||
Write-Warning "Unable to set $Name due to unhandled exception"
|
||||
Write-Warning $psitem.Exception.StackTrace
|
||||
}
|
||||
}
|
40
functions/private/Set-WinUtilScheduledTask.ps1
Normal file
40
functions/private/Set-WinUtilScheduledTask.ps1
Normal file
@ -0,0 +1,40 @@
|
||||
function Set-WinUtilScheduledTask {
|
||||
<#
|
||||
|
||||
.DESCRIPTION
|
||||
This function will enable/disable the provided Scheduled Task
|
||||
|
||||
.EXAMPLE
|
||||
|
||||
Set-WinUtilScheduledTask -Name "Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" -State "Disabled"
|
||||
|
||||
#>
|
||||
param (
|
||||
$Name,
|
||||
$State
|
||||
)
|
||||
|
||||
Try{
|
||||
if($State -eq "Disabled"){
|
||||
Write-Host "Disabling Scheduled Task $Name"
|
||||
Disable-ScheduledTask -TaskName $Name -ErrorAction Stop
|
||||
}
|
||||
if($State -eq "Enabled"){
|
||||
Write-Host "Enabling Scheduled Task $Name"
|
||||
Enable-ScheduledTask -TaskName $Name -ErrorAction Stop
|
||||
}
|
||||
}
|
||||
Catch [System.Exception]{
|
||||
if($psitem.Exception.Message -like "*The system cannot find the file specified*"){
|
||||
Write-Warning "Scheduled Task $name was not Found"
|
||||
}
|
||||
Else{
|
||||
Write-Warning "Unable to set $Name due to unhandled exception"
|
||||
Write-Warning $psitem.Exception.Message
|
||||
}
|
||||
}
|
||||
Catch{
|
||||
Write-Warning "Unable to run script for $name due to unhandled exception"
|
||||
Write-Warning $psitem.Exception.StackTrace
|
||||
}
|
||||
}
|
43
functions/private/Set-WinUtilService.ps1
Normal file
43
functions/private/Set-WinUtilService.ps1
Normal file
@ -0,0 +1,43 @@
|
||||
Function Set-WinUtilService {
|
||||
<#
|
||||
|
||||
.DESCRIPTION
|
||||
This function will change the startup type of services and start/stop them as needed
|
||||
|
||||
.EXAMPLE
|
||||
|
||||
Set-WinUtilService -Name "HomeGroupListener" -StartupType "Manual"
|
||||
|
||||
#>
|
||||
param (
|
||||
$Name,
|
||||
$StartupType
|
||||
)
|
||||
Try{
|
||||
Write-Host "Setting Services $Name to $StartupType"
|
||||
Set-Service -Name $Name -StartupType $StartupType -ErrorAction Stop
|
||||
|
||||
if($StartupType -eq "Disabled"){
|
||||
Write-Host "Stopping $Name"
|
||||
Stop-Service -Name $Name -Force -ErrorAction Stop
|
||||
}
|
||||
if($StartupType -eq "Enabled"){
|
||||
Write-Host "Starting $Name"
|
||||
Start-Service -Name $Name -Force -ErrorAction Stop
|
||||
}
|
||||
}
|
||||
Catch [System.Exception]{
|
||||
if($psitem.Exception.Message -like "*Cannot find any service with service name*" -or
|
||||
$psitem.Exception.Message -like "*was not found on computer*"){
|
||||
Write-Warning "Service $name was not Found"
|
||||
}
|
||||
Else{
|
||||
Write-Warning "Unable to set $Name due to unhandled exception"
|
||||
Write-Warning $psitem.Exception.Message
|
||||
}
|
||||
}
|
||||
Catch{
|
||||
Write-Warning "Unable to set $Name due to unhandled exception"
|
||||
Write-Warning $psitem.Exception.StackTrace
|
||||
}
|
||||
}
|
27
functions/private/Test-WinUtilPackageManager.ps1
Normal file
27
functions/private/Test-WinUtilPackageManager.ps1
Normal file
@ -0,0 +1,27 @@
|
||||
function Test-WinUtilPackageManager {
|
||||
<#
|
||||
|
||||
.DESCRIPTION
|
||||
Checks for Winget or Choco depending on the paramater
|
||||
|
||||
#>
|
||||
|
||||
Param(
|
||||
[System.Management.Automation.SwitchParameter]$winget,
|
||||
[System.Management.Automation.SwitchParameter]$choco
|
||||
)
|
||||
|
||||
if($winget){
|
||||
if (Test-Path ~\AppData\Local\Microsoft\WindowsApps\winget.exe) {
|
||||
return $true
|
||||
}
|
||||
}
|
||||
|
||||
if($choco){
|
||||
if ((Get-Command -Name choco -ErrorAction Ignore) -and ($chocoVersion = (Get-Item "$env:ChocolateyInstall\choco.exe" -ErrorAction Ignore).VersionInfo.ProductVersion)){
|
||||
return $true
|
||||
}
|
||||
}
|
||||
|
||||
return $false
|
||||
}
|
22
functions/private/Update-WinUtilProgramWinget.ps1
Normal file
22
functions/private/Update-WinUtilProgramWinget.ps1
Normal file
@ -0,0 +1,22 @@
|
||||
Function Update-WinUtilProgramWinget {
|
||||
|
||||
<#
|
||||
|
||||
.DESCRIPTION
|
||||
This will update programs via Winget using a new powershell.exe instance to prevent the GUI from locking up.
|
||||
|
||||
#>
|
||||
|
||||
[ScriptBlock]$wingetinstall = {
|
||||
|
||||
$host.ui.RawUI.WindowTitle = """Winget Install"""
|
||||
|
||||
Start-Transcript $ENV:TEMP\winget-update.log -Append
|
||||
winget upgrade --all
|
||||
|
||||
Pause
|
||||
}
|
||||
|
||||
$global:WinGetInstall = Start-Process -Verb runas powershell -ArgumentList "-command invoke-command -scriptblock {$wingetinstall} -argumentlist '$($ProgramsToInstall -join ",")'" -PassThru
|
||||
|
||||
}
|
Reference in New Issue
Block a user