diff --git a/config/helperscript.ps1 b/config/helperscript.ps1 index a0b633cb83..0bef372ddb 100644 --- a/config/helperscript.ps1 +++ b/config/helperscript.ps1 @@ -1,4 +1,4 @@ -#This file is meant to assist in building out the json files inside this folder. +# This file is meant to assist in building out the json files inside this folder. #=========================================================================== # applications.json @@ -35,7 +35,7 @@ Example: #> -#Modify the variables and run his code. It will import the current file and add your addition. From there you can create a pull request. +# Modify the variables and run his code. It will import the current file and add your addition. From there you can create a pull request. #------Do not delete WPF------ $NameofButton = "WPF" + "" @@ -45,7 +45,7 @@ $ChocoCommand = "" $ButtonToAdd = New-Object psobject $jsonfile = Get-Content ./config/applications.json | ConvertFrom-Json -#remove if already exists +# Remove if already exists if($jsonfile.$NameofButton){ $jsonfile.psobject.Properties.remove($NameofButton) } @@ -88,7 +88,7 @@ Example: } #> -#Modify the variables and run his code. It will import the current file and add your addition. From there you can create a pull request. +# Modify the variables and run his code. It will import the current file and add your addition. From there you can create a pull request. $NameofButton = "" $commands = @( @@ -97,7 +97,7 @@ $commands = @( $jsonfile = Get-Content ./config/feature.json | ConvertFrom-Json -#remove if already exists +# Remove if already exists if($jsonfile.$NameofButton){ $jsonfile.psobject.Properties.remove($NameofButton) } @@ -150,7 +150,7 @@ Example: } #> -#Modify the variables and run his code. It will import the current file and add your addition. From there you can create a pull request. +# Modify the variables and run his code. It will import the current file and add your addition. From there you can create a pull request. $NameofButton = "WPF" + "" $commands = @( @@ -159,7 +159,7 @@ $commands = @( $jsonfile = Get-Content ./config/preset.json | ConvertFrom-Json -#remove if already exists +# Remove if already exists if($jsonfile.$NameofButton){ $jsonfile.psobject.Properties.remove($NameofButton) } @@ -286,11 +286,11 @@ Example: #> -#Modify the variables and run his code. It will import the current file and add your addition. From there you can create a pull request. -#Make sure to uncomment the sections you which to add. +# Modify the variables and run his code. It will import the current file and add your addition. From there you can create a pull request. +# Make sure to uncomment the sections you which to add. #$Registry = @( -# #to add more repeat this separated by a comma +# # To add more repeat this separated by a comma # @{ # Path = "" # Name = "" @@ -301,7 +301,7 @@ Example: #) #$Service = @( -# #to add more repeat this separated by a comma +# # To add more repeat this separated by a comma # @{ # Name = "" # StartupType = "" @@ -310,7 +310,7 @@ Example: #) #$ScheduledTask = @( -# #to add more repeat this separated by a comma +# # To add more repeat this separated by a comma # @{ # Name = "" # State = "" @@ -335,7 +335,7 @@ $NameofButton = "WPF" + "" $ButtonToAdd = New-Object psobject $jsonfile = Get-Content ./config/tweaks.json | ConvertFrom-Json -#remove if already exists +# Remove if already exists if($jsonfile.$NameofButton){ $jsonfile.psobject.Properties.remove($NameofButton) } @@ -378,7 +378,7 @@ Example: } #> -#Modify the variables and run his code. It will import the current file and add your addition. From there you can create a pull request. +# Modify the variables and run his code. It will import the current file and add your addition. From there you can create a pull request. $NameofProvider = "" -replace " ","_" $IPAddress = @{ @@ -389,7 +389,7 @@ $IPAddress = @{ $ButtonToAdd = New-Object psobject $jsonfile = Get-Content ./config/dns.json | ConvertFrom-Json -#remove if already exists +# Remove if already exists if($jsonfile.$NameofProvider){ $jsonfile.psobject.Properties.remove($NameofProvider) } diff --git a/functions/private/Get-WinUtilCheckBoxes.ps1 b/functions/private/Get-WinUtilCheckBoxes.ps1 index a572df04f5..1df0c84c96 100644 --- a/functions/private/Get-WinUtilCheckBoxes.ps1 +++ b/functions/private/Get-WinUtilCheckBoxes.ps1 @@ -2,13 +2,19 @@ Function Get-WinUtilCheckBoxes { <# - .DESCRIPTION - Function is meant to find all checkboxes that are checked on the specific tab and input them into a script. + .SYNOPSIS + Finds all checkboxes that are checked on the specific tab and inputs them into a script. - Outputed data will be the names of the checkboxes that were checked + .PARAMETER Group + The group of checkboxes to check - .EXAMPLE + .PARAMETER unCheck + Whether to uncheck the checkboxes that are checked. Defaults to true + .OUTPUTS + A List containing the name of each checked checkbox + + .EXAMPLE Get-WinUtilCheckBoxes "WPFInstall" #> diff --git a/functions/private/Get-WinUtilInstallerProcess.ps1 b/functions/private/Get-WinUtilInstallerProcess.ps1 index a297b539bf..eae2647653 100644 --- a/functions/private/Get-WinUtilInstallerProcess.ps1 +++ b/functions/private/Get-WinUtilInstallerProcess.ps1 @@ -1,9 +1,15 @@ function Get-WinUtilInstallerProcess { <# - - .DESCRIPTION - Meant to check for running processes and will return a boolean response - + + .SYNOPSIS + Checks if the given process is running + + .PARAMETER Process + The process to check + + .OUTPUTS + Boolean - True if the process is running + #> param($Process) diff --git a/functions/private/Get-WinUtilRegistry.ps1 b/functions/private/Get-WinUtilRegistry.ps1 index 33345a2099..9a39795cd3 100644 --- a/functions/private/Get-WinUtilRegistry.ps1 +++ b/functions/private/Get-WinUtilRegistry.ps1 @@ -1,13 +1,12 @@ function Get-WinUtilRegistry { <# - - .DESCRIPTION - This function will make all modifications to the registry - .EXAMPLE + .SYNOPSIS + Gets the value of a registry key + + .EXAMPLE + Get-WinUtilRegistry -Name "PublishUserActivities" -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Type "DWord" -Value "0" - Set-WinUtilRegistry -Name "PublishUserActivities" -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Type "DWord" -Value "0" - #> param ( $Name, diff --git a/functions/private/Get-WinUtilToggleStatus.ps1 b/functions/private/Get-WinUtilToggleStatus.ps1 index a9742ff5e2..b0386904c3 100644 --- a/functions/private/Get-WinUtilToggleStatus.ps1 +++ b/functions/private/Get-WinUtilToggleStatus.ps1 @@ -1,12 +1,15 @@ Function Get-WinUtilToggleStatus { <# - - .DESCRIPTION - Meant to pull the registry keys for a toggle switch and returns true or false - True should mean status is enabled - False should mean status is disabled - + .SYNOPSIS + Pulls the registry keys for the given toggle switch and checks whether the toggle should be checked or unchecked + + .PARAMETER ToggleSwitch + The name of the toggle to check + + .OUTPUTS + Boolean to set the toggle's status to + #> Param($ToggleSwitch) diff --git a/functions/private/Get-WinUtilVariables.ps1 b/functions/private/Get-WinUtilVariables.ps1 index 32e536e4a0..d612e57c34 100644 --- a/functions/private/Get-WinUtilVariables.ps1 +++ b/functions/private/Get-WinUtilVariables.ps1 @@ -1,10 +1,13 @@ function Get-WinUtilVariables { <# - - .DESCRIPTION - placeholder - + + .SYNOPSIS + Gets every form object of the provided type + + .OUTPUTS + List containing every object that matches the provided type + #> param ( [Parameter()] diff --git a/functions/private/Install-WinUtilChoco.ps1 b/functions/private/Install-WinUtilChoco.ps1 index 9585858d00..e0890489db 100644 --- a/functions/private/Install-WinUtilChoco.ps1 +++ b/functions/private/Install-WinUtilChoco.ps1 @@ -1,10 +1,10 @@ function Install-WinUtilChoco { <# - - .DESCRIPTION - Function is meant to ensure Choco is installed - + + .SYNOPSIS + Installs Chocolatey if it is not already installed + #> try{ @@ -16,7 +16,7 @@ function Install-WinUtilChoco { } Write-Host "Seems Chocolatey is not installed, installing now?" - #Let user decide if he wants to install Chocolatey + # Let user decide if they want 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 diff --git a/functions/private/Install-WinUtilProgramWinget.ps1 b/functions/private/Install-WinUtilProgramWinget.ps1 index 13b2afdeb7..16776c4299 100644 --- a/functions/private/Install-WinUtilProgramWinget.ps1 +++ b/functions/private/Install-WinUtilProgramWinget.ps1 @@ -1,12 +1,19 @@ 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. - + .SYNOPSIS + Manages the provided programs using Winget + + .PARAMETER ProgramsToInstall + A list of programs to manage + + .PARAMETER manage + The action to perform on the programs, can be either 'Installing' or 'Uninstalling' + + .NOTES + The triple quotes are required any time you need a " in a normal script block. + #> param( diff --git a/functions/private/Install-WinUtilWinget.ps1 b/functions/private/Install-WinUtilWinget.ps1 index 3681483cd1..b04e6d9441 100644 --- a/functions/private/Install-WinUtilWinget.ps1 +++ b/functions/private/Install-WinUtilWinget.ps1 @@ -5,25 +5,25 @@ function Get-LatestHash { $WebClient.DownloadFile($shaUrl, $shaFile) Get-Content $shaFile - } +} function Install-WinUtilWinget { - + <# - - .DESCRIPTION - Function is meant to ensure winget is installed - + + .SYNOPSIS + Installs Winget if it is not already 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 + # 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 + # Gets the computer's information if ($null -eq $sync.ComputerInfo){ $ComputerInfo = Get-ComputerInfo -ErrorAction Stop } @@ -32,7 +32,7 @@ function Install-WinUtilWinget { } if (($ComputerInfo.WindowsVersion) -lt "1809") { - #Checks if Windows Version is too old for winget + # Checks if Windows Version is too old for winget Write-Host "Winget is not supported on this version of Windows (Pre-1809)" return } diff --git a/functions/private/Invoke-WinUtilBingSearch.ps1 b/functions/private/Invoke-WinUtilBingSearch.ps1 index 9d6fb56ae2..21574b6838 100644 --- a/functions/private/Invoke-WinUtilBingSearch.ps1 +++ b/functions/private/Invoke-WinUtilBingSearch.ps1 @@ -1,9 +1,12 @@ function Invoke-WinUtilBingSearch { - <# - - .DESCRIPTION - Sets Bing Search on or off - + <# + + .SYNOPSIS + Disables/Enables Bing Search + + .PARAMETER Enabled + Indicates whether to enable or disable Bing Search + #> Param($Enabled) Try{ diff --git a/functions/private/Invoke-WinUtilCurrentSystem.ps1 b/functions/private/Invoke-WinUtilCurrentSystem.ps1 index ba8d30225b..eda05c3756 100644 --- a/functions/private/Invoke-WinUtilCurrentSystem.ps1 +++ b/functions/private/Invoke-WinUtilCurrentSystem.ps1 @@ -2,13 +2,10 @@ Function Invoke-WinUtilCurrentSystem { <# - .DESCRIPTION - Function is meant to read existing system registry and check according configuration. - - Example: Is telemetry enabled? check the box. - - .EXAMPLE + .SYNOPSIS + Checks to see what tweaks have already been applied and what programs are installed, and checks the according boxes + .EXAMPLE Get-WinUtilCheckBoxes "WPFInstall" #> diff --git a/functions/private/Invoke-WinUtilDarkMode.ps1 b/functions/private/Invoke-WinUtilDarkMode.ps1 index c800247744..064259f50f 100644 --- a/functions/private/Invoke-WinUtilDarkMode.ps1 +++ b/functions/private/Invoke-WinUtilDarkMode.ps1 @@ -1,9 +1,12 @@ Function Invoke-WinUtilDarkMode { - <# - - .DESCRIPTION - Sets Dark Mode on or off - + <# + + .SYNOPSIS + Enables/Disables Dark Mode + + .PARAMETER DarkMoveEnabled + Indicates the current dark mode state + #> Param($DarkMoveEnabled) Try{ diff --git a/functions/private/Invoke-WinUtilFeatureInstall.ps1 b/functions/private/Invoke-WinUtilFeatureInstall.ps1 index e5968ee5ad..8f197e1dfe 100644 --- a/functions/private/Invoke-WinUtilFeatureInstall.ps1 +++ b/functions/private/Invoke-WinUtilFeatureInstall.ps1 @@ -1,9 +1,9 @@ function Invoke-WinUtilFeatureInstall { <# - - .DESCRIPTION - This function converts all the values from the tweaks.json and routes them to the appropriate function - + + .SYNOPSIS + Converts all the values from the tweaks.json and routes them to the appropriate function + #> param( diff --git a/functions/private/Invoke-WinUtilScript.ps1 b/functions/private/Invoke-WinUtilScript.ps1 index 329f76f953..e9516dfe9d 100644 --- a/functions/private/Invoke-WinUtilScript.ps1 +++ b/functions/private/Invoke-WinUtilScript.ps1 @@ -1,14 +1,19 @@ function Invoke-WinUtilScript { <# - - .DESCRIPTION - This function will run a separate powershell script. Meant for things that can't be handled with the other functions - .EXAMPLE + .SYNOPSIS + Invokes the provided scriptblock. Intended for things that can't be handled with the other functions. + + .PARAMETER Name + The name of the scriptblock being invoked + + .PARAMETER scriptblock + The scriptblock to be invoked + .EXAMPLE $Scriptblock = [scriptblock]::Create({"Write-output 'Hello World'"}) Invoke-WinUtilScript -ScriptBlock $scriptblock -Name "Hello World" - + #> param ( $Name, diff --git a/functions/private/Invoke-WinUtilTweaks.ps1 b/functions/private/Invoke-WinUtilTweaks.ps1 index a345b0a18f..2a61555c09 100644 --- a/functions/private/Invoke-WinUtilTweaks.ps1 +++ b/functions/private/Invoke-WinUtilTweaks.ps1 @@ -1,9 +1,15 @@ function Invoke-WinUtilTweaks { <# - - .DESCRIPTION - This function converts all the values from the tweaks.json and routes them to the appropriate function - + + .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( diff --git a/functions/private/Remove-WinUtilAPPX.ps1 b/functions/private/Remove-WinUtilAPPX.ps1 index dd6c25bdb3..40fa9f9a87 100644 --- a/functions/private/Remove-WinUtilAPPX.ps1 +++ b/functions/private/Remove-WinUtilAPPX.ps1 @@ -1,13 +1,15 @@ function Remove-WinUtilAPPX { <# - - .DESCRIPTION - This function will remove any of the provided APPX names - .EXAMPLE + .SYNOPSIS + Removes all APPX packages that match the given name + .PARAMETER Name + The name of the APPX package to remove + + .EXAMPLE Remove-WinUtilAPPX -Name "Microsoft.Microsoft3DViewer" - + #> param ( $Name diff --git a/functions/private/Set-WinUtilDNS.ps1 b/functions/private/Set-WinUtilDNS.ps1 index daf7e7522e..b636617cb9 100644 --- a/functions/private/Set-WinUtilDNS.ps1 +++ b/functions/private/Set-WinUtilDNS.ps1 @@ -1,13 +1,15 @@ 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 + .SYNOPSIS + Sets the DNS of all interfaces that are in the "Up" state. It will lookup the values from the DNS.Json file + .PARAMETER DNSProvider + The DNS provider to set the DNS server to + + .EXAMPLE Set-WinUtilDNS -DNSProvider "google" - + #> param($DNSProvider) if($DNSProvider -eq "Default"){return} diff --git a/functions/private/Set-WinUtilRegistry.ps1 b/functions/private/Set-WinUtilRegistry.ps1 index 58be434538..e4606952c3 100644 --- a/functions/private/Set-WinUtilRegistry.ps1 +++ b/functions/private/Set-WinUtilRegistry.ps1 @@ -1,14 +1,25 @@ function Set-WinUtilRegistry { <# - - .DESCRIPTION - This function will make all modifications to the registry - .EXAMPLE + .SYNOPSIS + Modifies the registry based on the given inputs + .PARAMETER Name + The name of the key to modify + + .PARAMETER Path + The path to the key + + .PARAMETER Type + The type of value to set the key to + + .PARAMETER Value + The value to set the key to + + .EXAMPLE Set-WinUtilRegistry -Name "PublishUserActivities" -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Type "DWord" -Value "0" - - #> + + #> param ( $Name, $Path, diff --git a/functions/private/Set-WinUtilRestorePoint.ps1 b/functions/private/Set-WinUtilRestorePoint.ps1 index 3fd73403be..ad80be9673 100644 --- a/functions/private/Set-WinUtilRestorePoint.ps1 +++ b/functions/private/Set-WinUtilRestorePoint.ps1 @@ -1,10 +1,10 @@ function Set-WinUtilRestorePoint { <# - - .DESCRIPTION - This function will make a Restore Point - #> + .SYNOPSIS + Creates a Restore Point + + #> # Check if the user has administrative privileges if (-Not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { diff --git a/functions/private/Set-WinUtilScheduledTask.ps1 b/functions/private/Set-WinUtilScheduledTask.ps1 index fc1c07e3a5..d9d5262aec 100644 --- a/functions/private/Set-WinUtilScheduledTask.ps1 +++ b/functions/private/Set-WinUtilScheduledTask.ps1 @@ -1,13 +1,18 @@ function Set-WinUtilScheduledTask { <# - - .DESCRIPTION - This function will enable/disable the provided Scheduled Task - .EXAMPLE + .SYNOPSIS + Enables/Disables the provided Scheduled Task + .PARAMETER Name + The path to the Scheduled Task + + .PARAMETER State + The State to set the Task to + + .EXAMPLE Set-WinUtilScheduledTask -Name "Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" -State "Disabled" - + #> param ( $Name, diff --git a/functions/private/Set-WinUtilService.ps1 b/functions/private/Set-WinUtilService.ps1 index ee03944b15..da237d639e 100644 --- a/functions/private/Set-WinUtilService.ps1 +++ b/functions/private/Set-WinUtilService.ps1 @@ -1,14 +1,19 @@ Function Set-WinUtilService { <# - - .DESCRIPTION - This function will change the startup type of services and start/stop them as needed - .EXAMPLE + .SYNOPSIS + Changes the startup type of the given service + + .PARAMETER Name + The name of the service to modify + + .PARAMETER StartupType + The startup type to set the service to + .EXAMPLE Set-WinUtilService -Name "HomeGroupListener" -StartupType "Manual" - - #> + + #> param ( $Name, $StartupType diff --git a/functions/private/Set-WinUtilUiTheme.ps1 b/functions/private/Set-WinUtilUiTheme.ps1 index 5cd3eeb7b5..22526bf206 100644 --- a/functions/private/Set-WinUtilUiTheme.ps1 +++ b/functions/private/Set-WinUtilUiTheme.ps1 @@ -1,13 +1,18 @@ function Set-WinUtilUITheme { <# - - .DESCRIPTION - This function will set theme to the XAML file - .EXAMPLE + .SYNOPSIS + Sets the theme of the XAML file + .PARAMETER inputXML + A string representing the XAML object to modify + + .PARAMETER themeName + The name of the theme to set the XAML to. Defaults to 'matrix' + + .EXAMPLE Set-WinUtilUITheme -inputXAML $inputXAML - + #> param ( diff --git a/functions/private/Test-WinUtilPackageManager.ps1 b/functions/private/Test-WinUtilPackageManager.ps1 index a4624c53d5..b548265a33 100644 --- a/functions/private/Test-WinUtilPackageManager.ps1 +++ b/functions/private/Test-WinUtilPackageManager.ps1 @@ -1,9 +1,15 @@ function Test-WinUtilPackageManager { <# - - .DESCRIPTION - Checks for Winget or Choco depending on the parameter - + + .SYNOPSIS + Checks if Winget and/or Choco are installed + + .PARAMETER winget + Check if Winget is installed + + .PARAMETER choco + Check if Chocolatey is installed + #> Param( diff --git a/functions/private/Update-WinUtilProgramWinget.ps1 b/functions/private/Update-WinUtilProgramWinget.ps1 index 6835972fc9..5deac59cbe 100644 --- a/functions/private/Update-WinUtilProgramWinget.ps1 +++ b/functions/private/Update-WinUtilProgramWinget.ps1 @@ -1,10 +1,10 @@ Function Update-WinUtilProgramWinget { <# - - .DESCRIPTION - This will update programs via Winget using a new powershell.exe instance to prevent the GUI from locking up. - + + .SYNOPSIS + This will update all programs using Winget + #> [ScriptBlock]$wingetinstall = { diff --git a/functions/public/Invoke-WPFButton.ps1 b/functions/public/Invoke-WPFButton.ps1 index cdb1da5e23..b25d1531f0 100644 --- a/functions/public/Invoke-WPFButton.ps1 +++ b/functions/public/Invoke-WPFButton.ps1 @@ -1,17 +1,18 @@ function Invoke-WPFButton { <# - - .DESCRIPTION - Meant to make creating buttons easier. There is a section below in the gui that will assign this function to every button. - This way you can dictate what each button does from this function. - - Input will be the name of the button that is clicked. + + .SYNOPSIS + Invokes the function associated with the clicked button + + .PARAMETER Button + The name of the button that was clicked + #> Param ([string]$Button) - #Use this to get the name of the button + # Use this to get the name of the button #[System.Windows.MessageBox]::Show("$Button","Chris Titus Tech's Windows Utility","OK","Info") Switch -Wildcard ($Button){ diff --git a/functions/public/Invoke-WPFControlPanel.ps1 b/functions/public/Invoke-WPFControlPanel.ps1 index 713ec3cd5e..f5574a1188 100644 --- a/functions/public/Invoke-WPFControlPanel.ps1 +++ b/functions/public/Invoke-WPFControlPanel.ps1 @@ -1,9 +1,12 @@ function Invoke-WPFControlPanel { - <# - - .DESCRIPTION - Simple Switch for legacy windows - + <# + + .SYNOPSIS + Opens the requested legacy panel + + .PARAMETER Panel + The panel to open + #> param($Panel) diff --git a/functions/public/Invoke-WPFFeatureInstall.ps1 b/functions/public/Invoke-WPFFeatureInstall.ps1 index 70411ce0fe..091a88a007 100644 --- a/functions/public/Invoke-WPFFeatureInstall.ps1 +++ b/functions/public/Invoke-WPFFeatureInstall.ps1 @@ -1,9 +1,9 @@ function Invoke-WPFFeatureInstall { - <# - - .DESCRIPTION - GUI Function to install Windows Features - + <# + + .SYNOPSIS + Installs selected Windows Features + #> if($sync.ProcessRunning){ diff --git a/functions/public/Invoke-WPFFixesNetwork.ps1 b/functions/public/Invoke-WPFFixesNetwork.ps1 index 614c0567e3..94ba11bda6 100644 --- a/functions/public/Invoke-WPFFixesNetwork.ps1 +++ b/functions/public/Invoke-WPFFixesNetwork.ps1 @@ -1,14 +1,18 @@ function Invoke-WPFFixesNetwork { <# - - .DESCRIPTION - PlaceHolder - + + .SYNOPSIS + Resets various network configurations + #> Write-Host "Resetting Network with netsh" + + # Reset WinSock catalog to a clean state Start-Process -NoNewWindow -FilePath "netsh" -ArgumentList "winsock", "reset" + # Resets WinHTTP proxy setting to DIRECT Start-Process -NoNewWindow -FilePath "netsh" -ArgumentList "winhttp", "reset", "proxy" + # Removes all user configured IP settings Start-Process -NoNewWindow -FilePath "netsh" -ArgumentList "int", "ip", "reset" Write-Host "Process complete. Please reboot your computer." @@ -19,7 +23,7 @@ function Invoke-WPFFixesNetwork { $MessageIcon = [System.Windows.MessageBoxImage]::Information [System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon) - Write-Host "=================================" - Write-Host "-- Reset Network Configuration --" - Write-Host "=================================" + Write-Host "==========================================" + Write-Host "-- Network Configuration has been Reset --" + Write-Host "==========================================" } \ No newline at end of file diff --git a/functions/public/Invoke-WPFFixesUpdate.ps1 b/functions/public/Invoke-WPFFixesUpdate.ps1 index c23449acd8..7e170b538e 100644 --- a/functions/public/Invoke-WPFFixesUpdate.ps1 +++ b/functions/public/Invoke-WPFFixesUpdate.ps1 @@ -1,13 +1,13 @@ function Invoke-WPFFixesUpdate { <# - - .DESCRIPTION - PlaceHolder - + + .SYNOPSIS + Performs various tasks in an attempt to repair Windows Update + #> - ### Reset Windows Update Script - reregister dlls, services, and remove registry entries. + # Reset Windows Update Script - reregister dlls, services, and remove registry entries Write-Host "1. Stopping Windows Update Services..." Stop-Service -Name BITS Stop-Service -Name wuauserv @@ -83,7 +83,7 @@ Write-Host "12) Forcing discovery..." $MessageIcon = [System.Windows.MessageBoxImage]::Information [System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon) - Write-Host "=================================" - Write-Host "-- Reset ALL Updates to Factory -" - Write-Host "=================================" + Write-Host "===============================================" + Write-Host "-- Reset All Windows Update Settings to Stock -" + Write-Host "===============================================" } \ No newline at end of file diff --git a/functions/public/Invoke-WPFFormVariables.ps1 b/functions/public/Invoke-WPFFormVariables.ps1 index f2e4a3d2e8..5905e0f8cd 100644 --- a/functions/public/Invoke-WPFFormVariables.ps1 +++ b/functions/public/Invoke-WPFFormVariables.ps1 @@ -1,9 +1,9 @@ Function Invoke-WPFFormVariables { <# - - .DESCRIPTION - PlaceHolder - + + .SYNOPSIS + Prints the logo + #> #If ($global:ReadmeDisplay -ne $true) { Write-Host "If you need to reference this display again, run Get-FormVariables" -ForegroundColor Yellow; $global:ReadmeDisplay = $true } diff --git a/functions/public/Invoke-WPFGetInstalled.ps1 b/functions/public/Invoke-WPFGetInstalled.ps1 index 09a296fb5f..3765abfb0b 100644 --- a/functions/public/Invoke-WPFGetInstalled.ps1 +++ b/functions/public/Invoke-WPFGetInstalled.ps1 @@ -1,8 +1,11 @@ function Invoke-WPFGetInstalled { <# - .DESCRIPTION - placeholder + .SYNOPSIS + Invokes the function that gets the checkboxes to check in a new runspace + + .PARAMETER checkbox + Indicates whether to check for installed 'winget' programs or applied 'tweaks' #> param($checkbox) diff --git a/functions/public/Invoke-WPFImpex.ps1 b/functions/public/Invoke-WPFImpex.ps1 index a6a14b230f..29675b2008 100644 --- a/functions/public/Invoke-WPFImpex.ps1 +++ b/functions/public/Invoke-WPFImpex.ps1 @@ -1,13 +1,18 @@ function Invoke-WPFImpex { <# - - .DESCRIPTION - This function handles importing and exporting of the checkboxes checked for the tweaks section - .EXAMPLE + .SYNOPSIS + Handles importing and exporting of the checkboxes checked for the tweaks section + + .PARAMETER type + Indicates whether to 'import' or 'export' + + .PARAMETER checkbox + The checkbox to export to a file or apply the imported file to + .EXAMPLE Invoke-WPFImpex -type "export" - + #> param( $type, diff --git a/functions/public/Invoke-WPFInstall.ps1 b/functions/public/Invoke-WPFInstall.ps1 index 484f4b273b..f8b87bd7ca 100644 --- a/functions/public/Invoke-WPFInstall.ps1 +++ b/functions/public/Invoke-WPFInstall.ps1 @@ -1,9 +1,9 @@ function Invoke-WPFInstall { <# - - .DESCRIPTION - PlaceHolder - + + .SYNOPSIS + Installs the selected programs using winget + #> if($sync.ProcessRunning){ @@ -28,7 +28,7 @@ function Invoke-WPFInstall { # Ensure winget is installed Install-WinUtilWinget - # Install all winget programs in new window + # Install all selected programs in new window Install-WinUtilProgramWinget -ProgramsToInstall $WingetInstall $ButtonType = [System.Windows.MessageBoxButton]::OK diff --git a/functions/public/Invoke-WPFInstallUpgrade.ps1 b/functions/public/Invoke-WPFInstallUpgrade.ps1 index 8e5e31f172..c2fb9df1fe 100644 --- a/functions/public/Invoke-WPFInstallUpgrade.ps1 +++ b/functions/public/Invoke-WPFInstallUpgrade.ps1 @@ -1,9 +1,9 @@ function Invoke-WPFInstallUpgrade { <# - - .DESCRIPTION - PlaceHolder - + + .SYNOPSIS + Invokes the function that upgrades all installed programs using winget + #> if(!(Test-WinUtilPackageManager -winget)){ Write-Host "===========================================" diff --git a/functions/public/Invoke-WPFPanelAutologin.ps1 b/functions/public/Invoke-WPFPanelAutologin.ps1 index 1cd14ef98c..5291869a51 100644 --- a/functions/public/Invoke-WPFPanelAutologin.ps1 +++ b/functions/public/Invoke-WPFPanelAutologin.ps1 @@ -1,9 +1,9 @@ function Invoke-WPFPanelAutologin { <# - - .DESCRIPTION - PlaceHolder - + + .SYNOPSIS + Enables autologin using Sysinternals Autologon.exe + #> curl.exe -ss "https://live.sysinternals.com/Autologon.exe" -o $env:temp\autologin.exe # Official Microsoft recommendation https://learn.microsoft.com/en-us/sysinternals/downloads/autologon cmd /c $env:temp\autologin.exe /accepteula diff --git a/functions/public/Invoke-WPFPanelDISM.ps1 b/functions/public/Invoke-WPFPanelDISM.ps1 index 9212682ceb..a1d266cfc0 100644 --- a/functions/public/Invoke-WPFPanelDISM.ps1 +++ b/functions/public/Invoke-WPFPanelDISM.ps1 @@ -1,9 +1,26 @@ function Invoke-WPFPanelDISM { <# - - .DESCRIPTION - PlaceHolder - + + .SYNOPSIS + Checks for system corruption using Chkdsk, SFC, and DISM + + .DESCRIPTION + 1. Chkdsk - Fixes disk and filesystem corruption + 2. SFC Run 1 - Fixes system file corruption, and fixes DISM if it was corrupted + 3. DISM - Fixes system image corruption, and fixes SFC's system image if it was corrupted + 4. SFC Run 2 - Fixes system file corruption, this time with an almost guaranteed uncorrupted system image + + .NOTES + Command Arguments: + 1. Chkdsk + /Scan - Runs an online scan on the system drive, attempts to fix any corruption, and queues other corruption for fixing on reboot + 2. SFC + /ScanNow - Performs a scan of the system files and fixes any corruption + 3. DISM - Fixes system image corruption, and fixes SFC's system image if it was corrupted + /Online - Fixes the currently running system image + /Cleanup-Image - Performs cleanup operations on the image, could remove some unneeded temporary files + /Restorehealth - Performs a scan of the image and fixes any corruption + #> Start-Process PowerShell -ArgumentList "Write-Host '(1/4) Chkdsk' -ForegroundColor Green; Chkdsk /scan; Write-Host '`n(2/4) SFC - 1st scan' -ForegroundColor Green; sfc /scannow; diff --git a/functions/public/Invoke-WPFPresets.ps1 b/functions/public/Invoke-WPFPresets.ps1 index 6e53571402..4b61e40bc6 100644 --- a/functions/public/Invoke-WPFPresets.ps1 +++ b/functions/public/Invoke-WPFPresets.ps1 @@ -1,8 +1,17 @@ function Invoke-WPFPresets { <# - .DESCRIPTION - Meant to make settings presets easier in the tweaks tab. Will pull the data from config/preset.json + .SYNOPSIS + Sets the options in the tweaks panel to the given preset + + .PARAMETER preset + The preset to set the options to + + .PARAMETER imported + If the preset is imported from a file, defaults to false + + .PARAMETER checkbox + The checkbox to set the options to, defaults to 'WPFTweaks' #> diff --git a/functions/public/Invoke-WPFRunspace.ps1 b/functions/public/Invoke-WPFRunspace.ps1 index e00b42bf21..9d16dac8f4 100644 --- a/functions/public/Invoke-WPFRunspace.ps1 +++ b/functions/public/Invoke-WPFRunspace.ps1 @@ -1,20 +1,21 @@ function Invoke-WPFRunspace { <# - - .DESCRIPTION - Simple function to make it easier to invoke a runspace from inside the script. - .EXAMPLE + .SYNOPSIS + Creates and invokes a runspace using the given scriptblock and argumentlist - $params = @{ - ScriptBlock = $sync.ScriptsInstallPrograms - ArgumentList = "Installadvancedip,Installbitwarden" - Verbose = $true - } + .PARAMETER ScriptBlock + The scriptblock to invoke in the runspace + + .PARAMETER ArgumentList + A list of arguments to pass to the runspace + + .EXAMPLE + Invoke-WPFRunspace ` + -ScriptBlock $sync.ScriptsInstallPrograms ` + -ArgumentList "Installadvancedip,Installbitwarden" ` - Invoke-WPFRunspace @params - #> [CmdletBinding()] @@ -23,18 +24,18 @@ function Invoke-WPFRunspace { $ArgumentList ) - #Crate a PowerShell instance. + # Create a PowerShell instance $script:powershell = [powershell]::Create() - #Add Scriptblock and Arguments to runspace + # Add Scriptblock and Arguments to runspace $script:powershell.AddScript($ScriptBlock) $script:powershell.AddArgument($ArgumentList) $script:powershell.RunspacePool = $sync.runspace - #Run our RunspacePool. + # Execute the RunspacePool $script:handle = $script:powershell.BeginInvoke() - #Cleanup our RunspacePool threads when they are complete ie. GC. + # Clean up the RunspacePool threads when they are complete, and invoke the garbage collector to clean up the memory if ($script:handle.IsCompleted) { $script:powershell.EndInvoke($script:handle) diff --git a/functions/public/Invoke-WPFShortcut.ps1 b/functions/public/Invoke-WPFShortcut.ps1 index 1b0377f815..7015725ac4 100644 --- a/functions/public/Invoke-WPFShortcut.ps1 +++ b/functions/public/Invoke-WPFShortcut.ps1 @@ -1,8 +1,11 @@ function Invoke-WPFShortcut { <# - .DESCRIPTION - Creates a shortcut + .SYNOPSIS + Creates a shortcut and prompts for a save location + + .PARAMETER ShortcutToAdd + The name of the shortcut to add #> param($ShortcutToAdd) diff --git a/functions/public/Invoke-WPFTab.ps1 b/functions/public/Invoke-WPFTab.ps1 index 2197695693..3e6310a5a3 100644 --- a/functions/public/Invoke-WPFTab.ps1 +++ b/functions/public/Invoke-WPFTab.ps1 @@ -1,10 +1,13 @@ function Invoke-WPFTab { <# - - .DESCRIPTION - Sole purpose of this function is to reduce duplicated code for switching between tabs. - + + .SYNOPSIS + Sets the selected tab to the tab that was clicked + + .PARAMETER ClickedTab + The name of the tab that was clicked + #> Param ($ClickedTab) diff --git a/functions/public/Invoke-WPFToggle.ps1 b/functions/public/Invoke-WPFToggle.ps1 index 451c950db1..23e26f28f0 100644 --- a/functions/public/Invoke-WPFToggle.ps1 +++ b/functions/public/Invoke-WPFToggle.ps1 @@ -1,17 +1,18 @@ function Invoke-WPFToggle { <# - - .DESCRIPTION - Meant to make creating toggle switches easier. There is a section below in the gui that will assign this function to every switch. - This way you can dictate what each button does from this function. - - Input will be the name of the toggle that is checked. + + .SYNOPSIS + Invokes the scriptblock for the given toggle + + .PARAMETER Button + The name of the toggle to invoke + #> Param ([string]$Button) - #Use this to get the name of the button + # Use this to get the name of the button #[System.Windows.MessageBox]::Show("$Button","Chris Titus Tech's Windows Utility","OK","Info") Switch -Wildcard ($Button){ diff --git a/functions/public/Invoke-WPFUltimatePerformance.ps1 b/functions/public/Invoke-WPFUltimatePerformance.ps1 index 014bcc2d3a..15c4df16b0 100644 --- a/functions/public/Invoke-WPFUltimatePerformance.ps1 +++ b/functions/public/Invoke-WPFUltimatePerformance.ps1 @@ -1,25 +1,27 @@ Function Invoke-WPFUltimatePerformance { <# - - .DESCRIPTION - PlaceHolder - + + .SYNOPSIS + Creates or removes the Ultimate Performance power scheme + + .PARAMETER State + Indicates whether to enable or disable the Ultimate Performance power scheme + #> param($State) Try{ if($state -eq "Enabled"){ - # Define the name and GUID of the power scheme you want to add + # Define the name and GUID of the power scheme $powerSchemeName = "Ultimate Performance" $powerSchemeGuid = "e9a42b02-d5df-448d-aa00-03f14749eb61" # Get all power schemes $schemes = powercfg /list | Out-String -Stream - # Find the scheme you want to add + # Check if the power scheme already exists $ultimateScheme = $schemes | Where-Object { $_ -match $powerSchemeName } - # If the scheme does not exist, add it if ($null -eq $ultimateScheme) { Write-Host "Power scheme '$powerSchemeName' not found. Adding..." @@ -34,13 +36,13 @@ Function Invoke-WPFUltimatePerformance { } } elseif($state -eq "Disabled"){ - # Define the name of the power scheme you want to remove + # Define the name of the power scheme $powerSchemeName = "Ultimate Performance" # Get all power schemes $schemes = powercfg /list | Out-String -Stream - # Find the scheme you want to remove + # Find the scheme to be removed $ultimateScheme = $schemes | Where-Object { $_ -match $powerSchemeName } # If the scheme exists, remove it diff --git a/functions/public/Invoke-WPFUnInstall.ps1 b/functions/public/Invoke-WPFUnInstall.ps1 index 2205db1553..5ab2292094 100644 --- a/functions/public/Invoke-WPFUnInstall.ps1 +++ b/functions/public/Invoke-WPFUnInstall.ps1 @@ -1,13 +1,13 @@ function Invoke-WPFUnInstall { <# - - .DESCRIPTION - PlaceHolder - + + .SYNOPSIS + Uninstalls the selected programs + #> if($sync.ProcessRunning){ - $msg = "Install process is currently running." + $msg = "Install process is currently running" [System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning) return } @@ -22,7 +22,7 @@ function Invoke-WPFUnInstall { $ButtonType = [System.Windows.MessageBoxButton]::YesNo $MessageboxTitle = "Are you sure?" - $Messageboxbody = ("This will uninstall the following applications `n $WingetInstall") + $Messageboxbody = ("This will uninstall the following applications: `n $WingetInstall") $MessageIcon = [System.Windows.MessageBoxImage]::Information $confirm = [System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon) @@ -34,7 +34,7 @@ function Invoke-WPFUnInstall { try{ $sync.ProcessRunning = $true - # Install all winget programs in new window + # Install all selected programs in new window Install-WinUtilProgramWinget -ProgramsToInstall $WingetInstall -Manage "Uninstalling" $ButtonType = [System.Windows.MessageBoxButton]::OK @@ -45,12 +45,12 @@ function Invoke-WPFUnInstall { [System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon) Write-Host "===========================================" - Write-Host "-- Uninstalls have finished ---" + Write-Host "-- Uninstalls have finished ---" Write-Host "===========================================" } Catch { Write-Host "===========================================" - Write-Host "-- Winget failed to install ---" + Write-Host "-- Winget failed to install ---" Write-Host "===========================================" } $sync.ProcessRunning = $False diff --git a/functions/public/Invoke-WPFUpdatesdefault.ps1 b/functions/public/Invoke-WPFUpdatesdefault.ps1 index fb6caff74d..3e1cebdd2b 100644 --- a/functions/public/Invoke-WPFUpdatesdefault.ps1 +++ b/functions/public/Invoke-WPFUpdatesdefault.ps1 @@ -1,9 +1,9 @@ function Invoke-WPFUpdatesdefault { <# - - .DESCRIPTION - PlaceHolder - + + .SYNOPSIS + Resets Windows Update settings to default + #> If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU")) { New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Force | Out-Null @@ -39,7 +39,7 @@ function Invoke-WPFUpdatesdefault { Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "BranchReadinessLevel" -ErrorAction SilentlyContinue Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "DeferFeatureUpdatesPeriodInDays" -ErrorAction SilentlyContinue Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Name "DeferQualityUpdatesPeriodInDays" -ErrorAction SilentlyContinue - Write-Host "=================================" - Write-Host "--- Updates Set to Default ---" - Write-Host "=================================" + Write-Host "===================================================" + Write-Host "--- Windows Update Settings Reset to Default ---" + Write-Host "===================================================" } \ No newline at end of file diff --git a/functions/public/Invoke-WPFUpdatesdisable.ps1 b/functions/public/Invoke-WPFUpdatesdisable.ps1 index 4cff5f5d11..3167039fd8 100644 --- a/functions/public/Invoke-WPFUpdatesdisable.ps1 +++ b/functions/public/Invoke-WPFUpdatesdisable.ps1 @@ -1,9 +1,12 @@ function Invoke-WPFUpdatesdisable { <# - - .DESCRIPTION - PlaceHolder - + + .SYNOPSIS + Disables Windows Update + + .NOTES + Disabling Windows Update is not recommended. This is only for advanced users who know what they are doing. + #> If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU")) { New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Force | Out-Null @@ -27,6 +30,6 @@ function Invoke-WPFUpdatesdisable { Get-Service -Name $service -ErrorAction SilentlyContinue | Set-Service -StartupType Disabled } Write-Host "=================================" - Write-Host "--- Updates ARE DISABLED ---" + Write-Host "--- Updates ARE DISABLED ---" Write-Host "=================================" } \ No newline at end of file diff --git a/functions/public/Invoke-WPFUpdatessecurity.ps1 b/functions/public/Invoke-WPFUpdatessecurity.ps1 index a40cf67707..e310d6a4b1 100644 --- a/functions/public/Invoke-WPFUpdatessecurity.ps1 +++ b/functions/public/Invoke-WPFUpdatessecurity.ps1 @@ -1,9 +1,16 @@ function Invoke-WPFUpdatessecurity { <# - - .DESCRIPTION - PlaceHolder - + + .SYNOPSIS + Sets Windows Update to recommended settings + + .DESCRIPTION + 1. Disables driver offering through Windows Update + 2. Disables Windows Update automatic restart + 3. Sets Windows Update to Semi-Annual Channel (Targeted) + 4. Defers feature updates for 365 days + 5. Defers quality updates for 4 days + #> Write-Host "Disabling driver offering through Windows Update..." If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Device Metadata")) { diff --git a/functions/public/Invoke-WPFtweaksbutton.ps1 b/functions/public/Invoke-WPFtweaksbutton.ps1 index 580ab0e598..a037653ea7 100644 --- a/functions/public/Invoke-WPFtweaksbutton.ps1 +++ b/functions/public/Invoke-WPFtweaksbutton.ps1 @@ -1,9 +1,9 @@ function Invoke-WPFtweaksbutton { <# - - .DESCRIPTION - PlaceHolder - + + .SYNOPSIS + Invokes the functions associated with each group of checkboxes + #> if($sync.ProcessRunning){ diff --git a/functions/public/Invoke-WPFundoall.ps1 b/functions/public/Invoke-WPFundoall.ps1 index 272636d3c8..354a26db4d 100644 --- a/functions/public/Invoke-WPFundoall.ps1 +++ b/functions/public/Invoke-WPFundoall.ps1 @@ -1,9 +1,9 @@ function Invoke-WPFundoall { <# - - .DESCRIPTION - PlaceHolder - + + .SYNOPSIS + Undoes every selected tweak + #> if($sync.ProcessRunning){ diff --git a/pester/configs.Tests.ps1 b/pester/configs.Tests.ps1 index 85a72f3b8d..fa69f6777d 100644 --- a/pester/configs.Tests.ps1 +++ b/pester/configs.Tests.ps1 @@ -1,13 +1,9 @@ -#region Load Variables needed for testing +# Import Config Files +$global:importedconfigs = @{} +Get-ChildItem .\config | Where-Object {$_.Extension -eq ".json"} | ForEach-Object { + $global:importedconfigs[$psitem.BaseName] = Get-Content $psitem.FullName | ConvertFrom-Json +} - #Config Files - $global:importedconfigs = @{} - Get-ChildItem .\config | Where-Object {$_.Extension -eq ".json"} | ForEach-Object { - $global:importedconfigs[$psitem.BaseName] = Get-Content $psitem.FullName | ConvertFrom-Json - } - - -#endregion Load Variables needed for testing #=========================================================================== # Tests - Application Installs diff --git a/pester/winutil.Tests.ps1 b/pester/winutil.Tests.ps1 index b1752ce645..0283b61ee6 100644 --- a/pester/winutil.Tests.ps1 +++ b/pester/winutil.Tests.ps1 @@ -1,15 +1,15 @@ -#region Load Variables needed for testing +# Load Variables needed for testing - ./Compile.ps1 +./Compile.ps1 - $script = Get-Content .\winutil.ps1 - $script[0..($script.count - 21)] | Out-File .\pester.ps1 +$script = Get-Content .\winutil.ps1 +# Remove the part of the script that shows the form, leaving only the variable and function declarations +$script[0..($script.count - 21)] | Out-File .\pester.ps1 -#endregion Load Variables needed for testing - BeforeAll { - . .\pester.ps1 + # Execute the truncated script, bringing the variabes into the current scope + . .\pester.ps1 } Describe "GUI" { diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 8c2c4bcbfc..39f1b0c718 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -1,32 +1,36 @@ # SPDX-License-Identifier: MIT -#Configure max thread count for RunspacePool. +# Set the maximum number of threads for the RunspacePool to the number of threads on the machine $maxthreads = [int]$env:NUMBER_OF_PROCESSORS -#Create a new session state for parsing variables ie hashtable into our runspace. +# Create a new session state for parsing variables into our runspace $hashVars = New-object System.Management.Automation.Runspaces.SessionStateVariableEntry -ArgumentList 'sync',$sync,$Null $InitialSessionState = [System.Management.Automation.Runspaces.InitialSessionState]::CreateDefault() -#Add the variable to the RunspacePool sessionstate +# Add the variable to the session state $InitialSessionState.Variables.Add($hashVars) -#Add functions +# Get every private function and add them to the session state $functions = Get-ChildItem function:\ | Where-Object {$_.name -like "*winutil*" -or $_.name -like "*WPF*"} foreach ($function in $functions){ $functionDefinition = Get-Content function:\$($function.name) $functionEntry = New-Object System.Management.Automation.Runspaces.SessionStateFunctionEntry -ArgumentList $($function.name), $functionDefinition - - # And add it to the iss object + $initialSessionState.Commands.Add($functionEntry) } -#Create our runspace pool. We are entering three parameters here min thread count, max thread count and host machine of where these runspaces should be made. -$sync.runspace = [runspacefactory]::CreateRunspacePool(1,$maxthreads,$InitialSessionState, $Host) +# Create the runspace pool +$sync.runspace = [runspacefactory]::CreateRunspacePool( + 1, # Minimum thread count + $maxthreads, # Maximum thread count + $InitialSessionState, # Initial session state + $Host # Machine to create runspaces on +) -#Open a RunspacePool instance. +# Open the RunspacePool instance $sync.runspace.Open() -#region exception classes +# Create classes for different exceptions class WingetFailedInstall : Exception { [string] $additionalData @@ -46,7 +50,6 @@ $sync.runspace.Open() GenericException($Message) : base($Message) {} } -#endregion exception classes $inputXML = $inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^ Write-Host "Unable to load Windows.Markup.XamlReader. Double-check syntax and ensure .net is installed." } @@ -116,7 +118,7 @@ $sync.keys | ForEach-Object { # Setup background config #=========================================================================== -#Load information in the background +# Load computer information in the background Invoke-WPFRunspace -ScriptBlock { $sync.ConfigLoaded = $False @@ -126,25 +128,32 @@ Invoke-WPFRunspace -ScriptBlock { } | Out-Null #=========================================================================== -# Shows the form +# Setup and Show the Form #=========================================================================== +# Print the logo Invoke-WPFFormVariables +# Check if Chocolatey is installed try{ Install-WinUtilChoco } Catch [ChocoFailedInstall]{ Write-Host "===========================================" - Write-Host "-- Chocolatey failed to install ---" + Write-Host "-- Chocolatey failed to install ---" Write-Host "===========================================" } + +# Set the titlebar $sync["Form"].title = $sync["Form"].title + " " + $sync.version +# Set the commands that will run when the form is closed $sync["Form"].Add_Closing({ $sync.runspace.Dispose() $sync.runspace.Close() [System.GC]::Collect() }) +# Show the form $sync["Form"].ShowDialog() | out-null -Stop-Transcript + +Stop-Transcript \ No newline at end of file diff --git a/scripts/start.ps1 b/scripts/start.ps1 index 3e7d803ed5..2f3f5156b3 100644 --- a/scripts/start.ps1 +++ b/scripts/start.ps1 @@ -8,10 +8,10 @@ Start-Transcript $ENV:TEMP\Winutil.log -Append -#Load DLLs +# Load DLLs Add-Type -AssemblyName System.Windows.Forms -# variable to sync between runspaces +# Variable to sync between runspaces $sync = [Hashtable]::Synchronized(@{}) $sync.PSScriptRoot = $PSScriptRoot $sync.version = "#{replaceme}"