From 1891ea7966b0822aa53427c55c7195be6d0c5d35 Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Sat, 29 Jun 2024 01:15:39 +0300 Subject: [PATCH] Remove trailing whitespace characters (#2149) * Remove All Trailing Whitespace Characters in '.ps1' Files * Remove All Trailing Whitespace Characters in '.json' Files * Remove All Trailing Whitespace Characters in '.yaml' Files * Remove All Trailing Whitespace Characters in Different Files * Remove Even More Trailing Whitespace Characters --- .github/workflows/pre-release.yaml | 2 +- .github/workflows/release.yaml | 2 +- .github/workflows/unittests.yaml | 4 +- Compile.ps1 | 2 +- README.md | 20 +-- config/applications.json | 2 +- config/themes.json | 4 +- config/tweaks.json | 84 ++++++------- edgeremoval.bat | 18 +-- functions/private/ConvertTo-Icon.ps1 | 36 +++--- functions/private/Copy-Files.ps1 | 18 +-- functions/private/Get-LocalizedYesNo.ps1 | 11 +- functions/private/Get-Oscdimg.ps1 | 8 +- functions/private/Get-TabXaml.ps1 | 6 +- functions/private/Get-WPFObjectName.ps1 | 8 +- functions/private/Get-WinUtilToggleStatus.ps1 | 8 +- functions/private/Get-WinUtilWingetLatest.ps1 | 4 +- .../private/Install-WinUtilProgramChoco.ps1 | 10 +- .../private/Install-WinUtilProgramWinget.ps1 | 16 +-- functions/private/Install-WinUtilWinget.ps1 | 2 +- functions/private/Invoke-MicroWin-Helper.ps1 | 66 +++++----- .../Invoke-WinUtilMouseAcceleration.ps1 | 6 +- .../private/Invoke-WinUtilStickyKeys.ps1 | 2 +- functions/private/Invoke-WinUtilTweaks.ps1 | 2 +- functions/private/Show-CustomDialog.ps1 | 18 +-- .../private/Test-WinUtilPackageManager.ps1 | 2 +- functions/public/Invoke-ScratchDialog.ps1 | 8 +- functions/public/Invoke-WPFFixesWinget.ps1 | 2 +- functions/public/Invoke-WPFGetIso.ps1 | 22 ++-- functions/public/Invoke-WPFImpex.ps1 | 4 +- functions/public/Invoke-WPFMicrowin.ps1 | 32 ++--- functions/public/Invoke-WPFOOSU.ps1 | 4 +- functions/public/Invoke-WPFPresets.ps1 | 2 +- functions/public/Invoke-WPFTweakPS7.ps1 | 4 +- functions/public/Invoke-WPFtweaksbutton.ps1 | 2 +- scripts/main.ps1 | 6 +- windev.ps1 | 2 +- xaml/inputXML.xaml | 114 +++++++++--------- 38 files changed, 282 insertions(+), 281 deletions(-) diff --git a/.github/workflows/pre-release.yaml b/.github/workflows/pre-release.yaml index 01b9a9f6..603739f5 100644 --- a/.github/workflows/pre-release.yaml +++ b/.github/workflows/pre-release.yaml @@ -15,7 +15,7 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v4 - + - name: Extract Version from winutil.ps1 id: extract_version run: | diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 5bf217bb..6728470a 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -11,7 +11,7 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v4 - + - name: Extract Version from winutil.ps1 id: extract_version run: | diff --git a/.github/workflows/unittests.yaml b/.github/workflows/unittests.yaml index a83604d4..659d9ab1 100644 --- a/.github/workflows/unittests.yaml +++ b/.github/workflows/unittests.yaml @@ -1,7 +1,7 @@ name: Unit Tests on: - push: + push: jobs: lint: @@ -34,7 +34,7 @@ jobs: run: | Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process Invoke-Pester -Path 'pester/*.Tests.ps1' -Output Detailed - + shell: pwsh env: TEMP: ${{ runner.temp }} \ No newline at end of file diff --git a/Compile.ps1 b/Compile.ps1 index 5a3494f5..a8bf570d 100644 --- a/Compile.ps1 +++ b/Compile.ps1 @@ -141,5 +141,5 @@ if ($run){ catch { Start-Process -FilePath "powershell" -ArgumentList ".\$scriptname" } - + } diff --git a/README.md b/README.md index 7525df50..6a113e55 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Version](https://img.shields.io/github/v/release/ChrisTitusTech/winutil?color=7a39fb)](https://github.com/ChrisTitusTech/winutil/releases/latest) -This utility is a compilation of Windows tasks I perform on each Windows system I use. It is meant to streamline *installs*, debloat with *tweaks*, troubleshoot with *config*, and fix Windows *updates*. I am extremely picky about any contributions to keep this project clean and efficient. +This utility is a compilation of Windows tasks I perform on each Windows system I use. It is meant to streamline *installs*, debloat with *tweaks*, troubleshoot with *config*, and fix Windows *updates*. I am extremely picky about any contributions to keep this project clean and efficient. ![screen-install](screen-install.png) @@ -29,7 +29,7 @@ irm https://christitus.com/win | iex ``` Courtesy of the issue raised at: [#144](/../../issues/144) -or by executing: +or by executing: ``` iwr -useb https://christitus.com/win | iex ``` @@ -85,15 +85,15 @@ If you are still having issues try changing your DNS provider to 1.1.1.1 || 1.0. - Install - Install Selection: Organize programs by category and facilitate installation by enabling users to select programs and initiate the installation process with a single click. - - - Upgrade All: Upgrade all existing programs to their latest versions, ensuring users have the most up-to-date and feature-rich software. - + + - Upgrade All: Upgrade all existing programs to their latest versions, ensuring users have the most up-to-date and feature-rich software. + - Uninstall Selection: Effortlessly uninstall selected programs, providing users with a streamlined way to remove unwanted software from their system. - + - Get Installed: Retrieve a comprehensive list of installed programs on the system, offering users visibility into the software currently installed on their computer. - + - Import / Export: Enable users to import or export the selection list of programs, allowing them to save their preferred program configurations or share them with others. This feature promotes convenience and flexibility in managing program selections across different systems. - + - Tweaks - Recommended Selection: Provides pre-defined templates tailored for desktop, laptop, and minimal configurations, allowing users to select recommended settings and optimizations specific to their system type. @@ -115,7 +115,7 @@ If you are still having issues try changing your DNS provider to 1.1.1.1 || 1.0. - Updates: - Default (Out of Box) Settings: Provides the default settings that come with Windows for updates. - + - Security (Recommended) Settings: Offers recommended settings, including a slight delay of feature updates by 2 years and installation of security updates 4 days after release. - Disable All Updates (Not Recommended!): Allows users to disable all Windows updates, but it's not recommended due to potential security risks. @@ -129,7 +129,7 @@ If you encounter any challenges or problems with the script, I kindly request th ## Contribute Code -Pull Requests are now handled directly on the MAIN branch. This was done since we can now select specific releases to launch via releases in GitHub. +Pull Requests are now handled directly on the MAIN branch. This was done since we can now select specific releases to launch via releases in GitHub. If doing a code change and you can submit a PR to main branch, but I am very selective about these. Do not use a code formatter, massive amounts of line changes, and make multiple feature changes. EACH FEATURE CHANGE SHOULD BE IT'S OWN Pull Request! diff --git a/config/applications.json b/config/applications.json index 25166b0d..3ae1faae 100644 --- a/config/applications.json +++ b/config/applications.json @@ -134,7 +134,7 @@ "description": "Azure Data Studio is a data management tool that enables you to work with SQL Server, Azure SQL DB and SQL DW from Windows, macOS and Linux.", "link": "https://docs.microsoft.com/sql/azure-data-studio/what-is-azure-data-studio", "winget": "Microsoft.AzureDataStudio" - }, + }, "barrier": { "category": "Utilities", "choco": "barrier", diff --git a/config/themes.json b/config/themes.json index f61c09ef..7500bb87 100644 --- a/config/themes.json +++ b/config/themes.json @@ -6,7 +6,7 @@ "MainBackgroundColor": "#FFFFFF", "LabelBackgroundColor": "#FAFAFA", "LinkForegroundColor": "#000000", - "LinkHoverForegroundColor": "#000000", + "LinkHoverForegroundColor": "#000000", "GroupBorderBackgroundColor": "#000000", "ComboBoxForegroundColor": "#000000", "ButtonInstallBackgroundColor": "#FFFFFF", @@ -31,7 +31,7 @@ "BorderColor": "#000000", "BorderOpacity": "0.2", "ShadowPulse": "Forever" - }, + }, "Matrix": { "ComboBoxBackgroundColor": "#000000", "LabelboxForegroundColor": "#FFEE58", diff --git a/config/tweaks.json b/config/tweaks.json index 45d7a388..637aa9dc 100644 --- a/config/tweaks.json +++ b/config/tweaks.json @@ -84,7 +84,7 @@ " Write-Host \"Turn on Hibernation\" Start-Process -FilePath powercfg -ArgumentList \"/hibernate on\" -NoNewWindow -Wait - + # Set hibernation as the default action Start-Process -FilePath powercfg -ArgumentList \"/change standby-timeout-ac 60\" -NoNewWindow -Wait Start-Process -FilePath powercfg -ArgumentList \"/change standby-timeout-dc 60\" -NoNewWindow -Wait @@ -96,14 +96,14 @@ " Write-Host \"Turn off Hibernation\" Start-Process -FilePath powercfg -ArgumentList \"/hibernate off\" -NoNewWindow -Wait - + # Set standby to detault values Start-Process -FilePath powercfg -ArgumentList \"/change standby-timeout-ac 15\" -NoNewWindow -Wait Start-Process -FilePath powercfg -ArgumentList \"/change standby-timeout-dc 15\" -NoNewWindow -Wait Start-Process -FilePath powercfg -ArgumentList \"/change monitor-timeout-ac 15\" -NoNewWindow -Wait Start-Process -FilePath powercfg -ArgumentList \"/change monitor-timeout-dc 15\" -NoNewWindow -Wait " - ] + ] }, "WPFTweaksHome": { "Content": "Disable Homegroup", @@ -2245,7 +2245,7 @@ Write-Host \"Please run this script as an administrator.\" return } - + # Check if System Restore is enabled for the main drive try { # Try getting restore points to check if System Restore is enabled @@ -2253,14 +2253,14 @@ } catch { Write-Host \"An error occurred while enabling System Restore: $_\" } - + # Check if the SystemRestorePointCreationFrequency value exists $exists = Get-ItemProperty -path \"HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\SystemRestore\" -Name \"SystemRestorePointCreationFrequency\" -ErrorAction SilentlyContinue if($null -eq $exists){ write-host 'Changing system to allow multiple restore points per day' Set-ItemProperty -Path \"HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\SystemRestore\" -Name \"SystemRestorePointCreationFrequency\" -Value \"0\" -Type DWord -Force -ErrorAction Stop | Out-Null } - + # Attempt to load the required module for Get-ComputerRestorePoint try { Import-Module Microsoft.PowerShell.Management -ErrorAction Stop @@ -2268,7 +2268,7 @@ Write-Host \"Failed to load the Microsoft.PowerShell.Management module: $_\" return } - + # Get all the restore points for the current day try { $existingRestorePoints = Get-ComputerRestorePoint | Where-Object { $_.CreationTime.Date -eq (Get-Date).Date } @@ -2276,11 +2276,11 @@ Write-Host \"Failed to retrieve restore points: $_\" return } - + # Check if there is already a restore point created today if ($existingRestorePoints.Count -eq 0) { $description = \"System Restore Point created by WinUtil\" - + Checkpoint-Computer -Description $description -RestorePointType \"MODIFY_SETTINGS\" Write-Host -ForegroundColor Green \"System Restore Point Created Successfully\" } @@ -2358,7 +2358,7 @@ "Order": "a025_", "registry": [ { - + "Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\WindowsCopilot", "Name": "TurnOffWindowsCopilot", "Type": "DWord", @@ -2383,7 +2383,7 @@ "InvokeScript": [ " Write-Host \"Remove Copilot\" - dism /online /remove-package /package-name:Microsoft.Windows.Copilot + dism /online /remove-package /package-name:Microsoft.Windows.Copilot " ], "UndoScript": [ @@ -2402,11 +2402,11 @@ "InvokeScript": [ " Write-Host \"Kill LMS\" - $serviceName = \"LMS\" + $serviceName = \"LMS\" Write-Host \"Stopping and disabling service: $serviceName\" Stop-Service -Name $serviceName -Force -ErrorAction SilentlyContinue; Set-Service -Name $serviceName -StartupType Disabled -ErrorAction SilentlyContinue; - + Write-Host \"Removing service: $serviceName\"; sc.exe delete $serviceName; @@ -2421,7 +2421,7 @@ } else { Write-Host \"All found LMS driver packages have been removed.\"; } - + Write-Host \"Searching and deleting LMS executable files\"; $programFilesDirs = @(\"C:\\Program Files\", \"C:\\Program Files (x86)\"); $lmsFiles = @(); @@ -2439,7 +2439,7 @@ Write-Host \"No LMS.exe files found in Program Files directories.\"; } else { Write-Host \"All found LMS.exe files have been deleted.\"; - } + } Write-Host 'Intel LMS vPro service has been disabled, removed, and blocked.'; " ], @@ -2449,7 +2449,7 @@ " ] - }, + }, "WPFTweaksRemoveOnedrive": { "Content": "Remove OneDrive", "Description": "Moves OneDrive files to Default Home Folders and Uninstalls it.", @@ -2457,7 +2457,7 @@ "panel": "1", "Order": "a030_", "InvokeScript": [ - " + " $OneDrivePath = $($env:OneDrive) Write-Host \"Removing OneDrive\" $regPath = \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OneDriveSetup.exe\" @@ -2473,7 +2473,7 @@ # Check if OneDrive got Uninstalled if (-not (Test-Path $regPath)){ Write-Host \"Copy downloaded Files from the OneDrive Folder to Root UserProfile\" - Start-Process -FilePath powershell -ArgumentList \"robocopy '$($OneDrivePath)' '$($env:USERPROFILE.TrimEnd())\\' /mov /e /xj\" -NoNewWindow -Wait + Start-Process -FilePath powershell -ArgumentList \"robocopy '$($OneDrivePath)' '$($env:USERPROFILE.TrimEnd())\\' /mov /e /xj\" -NoNewWindow -Wait Write-Host \"Removing OneDrive leftovers\" Remove-Item -Recurse -Force -ErrorAction SilentlyContinue \"$env:localappdata\\Microsoft\\OneDrive\" @@ -2574,25 +2574,25 @@ "Description": "Manages Adobe Services, Adobe Desktop Service, and Acrobat Updates", "category": "z__Advanced Tweaks - CAUTION", "panel": "1", - "Order": "a021_", + "Order": "a021_", "InvokeScript": [ " function CCStopper { $path = \"C:\\Program Files (x86)\\Common Files\\Adobe\\Adobe Desktop Common\\ADS\\Adobe Desktop Service.exe\" - + # Test if the path exists before proceeding if (Test-Path $path) { Takeown /f $path $acl = Get-Acl $path $acl.SetOwner([System.Security.Principal.NTAccount]\"Administrators\") $acl | Set-Acl $path - + Rename-Item -Path $path -NewName \"Adobe Desktop Service.exe.old\" -Force } else { Write-Host \"Adobe Desktop Service is not in the default location.\" } } - + function AcrobatUpdates { # Editing Acrobat Updates. The last folder before the key is dynamic, therefore using a script. @@ -2602,12 +2602,12 @@ # 3 = Automatically download and install updates (default value) # 4 = Notify the user when an update is available but don't download or install it automatically # = It notifies the user using Windows Notifications. It runs on startup without having to have a Service/Acrobat/Reader running, therefore 0 is the next best thing. - + $rootPath = \"HKLM:\\SOFTWARE\\WOW6432Node\\Adobe\\Adobe ARM\\Legacy\\Acrobat\" - + # Get all subkeys under the specified root path $subKeys = Get-ChildItem -Path $rootPath | Where-Object { $_.PSChildName -like \"{*}\" } - + # Loop through each subkey foreach ($subKey in $subKeys) { # Get the full registry path @@ -2630,7 +2630,7 @@ function RestoreCCService { $originalPath = \"C:\\Program Files (x86)\\Common Files\\Adobe\\Adobe Desktop Common\\ADS\\Adobe Desktop Service.exe.old\" $newPath = \"C:\\Program Files (x86)\\Common Files\\Adobe\\Adobe Desktop Common\\ADS\\Adobe Desktop Service.exe\" - + if (Test-Path -Path $originalPath) { Rename-Item -Path $originalPath -NewName \"Adobe Desktop Service.exe\" -Force Write-Host \"Adobe Desktop Service has been restored.\" @@ -2642,12 +2642,12 @@ function AcrobatUpdates { # Default Value: # 3 = Automatically download and install updates - + $rootPath = \"HKLM:\\SOFTWARE\\WOW6432Node\\Adobe\\Adobe ARM\\Legacy\\Acrobat\" - + # Get all subkeys under the specified root path $subKeys = Get-ChildItem -Path $rootPath | Where-Object { $_.PSChildName -like \"{*}\" } - + # Loop through each subkey foreach ($subKey in $subKeys) { # Get the full registry path @@ -2722,14 +2722,14 @@ "Description": "Reduce user interruptions by selectively blocking connections to Adobe's activation and telemetry servers. Credit: Ruddernation-Designs", "category": "z__Advanced Tweaks - CAUTION", "panel": "1", - "Order": "a021_", + "Order": "a021_", "InvokeScript": [ " # Define the URL of the remote HOSTS file and the local paths $remoteHostsUrl = \"https://raw.githubusercontent.com/Ruddernation-Designs/Adobe-URL-Block-List/master/hosts\" $localHostsPath = \"C:\\Windows\\System32\\drivers\\etc\\hosts\" $tempHostsPath = \"C:\\Windows\\System32\\drivers\\etc\\temp_hosts\" - + # Download the remote HOSTS file to a temporary location try { Invoke-WebRequest -Uri $remoteHostsUrl -OutFile $tempHostsPath @@ -2738,11 +2738,11 @@ catch { Write-Error \"Failed to download the HOSTS file. Error: $_\" } - + # Check if the AdobeNetBlock has already been started try { $localHostsContent = Get-Content $localHostsPath -ErrorAction Stop - + # Check if AdobeNetBlock markers exist $blockStartExists = $localHostsContent -like \"*#AdobeNetBlock-start*\" if ($blockStartExists) { @@ -2753,10 +2753,10 @@ $newBlockContent = $newBlockContent | Where-Object { $_ -notmatch \"^\\s*#\" -and $_ -ne \"\" } # Exclude empty lines and comments $newBlockHeader = \"#AdobeNetBlock-start\" $newBlockFooter = \"#AdobeNetBlock-end\" - + # Combine the contents, ensuring new block is properly formatted $combinedContent = $localHostsContent + $newBlockHeader, $newBlockContent, $newBlockFooter | Out-String - + # Write the combined content back to the original HOSTS file $combinedContent | Set-Content $localHostsPath -Encoding ASCII Write-Output \"Successfully added the AdobeNetBlock.\" @@ -2765,10 +2765,10 @@ catch { Write-Error \"Error during processing: $_\" } - + # Clean up temporary file Remove-Item $tempHostsPath -ErrorAction Ignore - + # Flush the DNS resolver cache try { Invoke-Expression \"ipconfig /flushdns\" @@ -2783,7 +2783,7 @@ " # Define the local path of the HOSTS file $localHostsPath = \"C:\\Windows\\System32\\drivers\\etc\\hosts\" - + # Load the content of the HOSTS file try { $hostsContent = Get-Content $localHostsPath -ErrorAction Stop @@ -2792,11 +2792,11 @@ Write-Error \"Failed to load the HOSTS file. Error: $_\" return } - + # Initialize flags and buffer for new content $recording = $true $newContent = @() - + # Iterate over each line of the HOSTS file foreach ($line in $hostsContent) { if ($line -match \"#AdobeNetBlock-start\") { @@ -2809,7 +2809,7 @@ $recording = $true } } - + # Write the filtered content back to the HOSTS file try { $newContent | Set-Content $localHostsPath -Encoding ASCII @@ -2818,7 +2818,7 @@ catch { Write-Error \"Failed to write back to the HOSTS file. Error: $_\" } - + # Flush the DNS resolver cache try { Invoke-Expression \"ipconfig /flushdns\" diff --git a/edgeremoval.bat b/edgeremoval.bat index b950e873..ff8556c4 100644 --- a/edgeremoval.bat +++ b/edgeremoval.bat @@ -37,7 +37,7 @@ function global:prepare_edge { ri 'Registry::HKEY_Users\S-1-5-21*\Software\Classes\microsoft-edge' -recurse -force -ea 0 ri 'Registry::HKEY_Users\S-1-5-21*\Software\Classes\MSEdgeHTM' -recurse -force -ea 0 ni "HKLM:\SOFTWARE\Classes\microsoft-edge\shell\open\command" -force -ea 0 >'' - sp "HKLM:\SOFTWARE\Classes\microsoft-edge\shell\open\command" '(Default)' "`"$MS`" --single-argument %%1" -force -ea 0 + sp "HKLM:\SOFTWARE\Classes\microsoft-edge\shell\open\command" '(Default)' "`"$MS`" --single-argument %%1" -force -ea 0 ni "HKLM:\SOFTWARE\Classes\MSEdgeHTM\shell\open\command" -force -ea 0 >'' sp "HKLM:\SOFTWARE\Classes\MSEdgeHTM\shell\open\command" '(Default)' "`"$MS`" --single-argument %%1" -force -ea 0 foreach ($p in 'HKLM:\SOFTWARE\Policies','HKLM:\SOFTWARE','HKLM:\SOFTWARE\WOW6432Node') { @@ -54,7 +54,7 @@ function global:prepare_edge { } ## helper for webview reinstall - restore webexperience (widgets) if available function global:prepare_webview { - $cfg = @{Register=$true; ForceApplicationShutdown=$true; ForceUpdateFromAnyVersion=$true; DisableDevelopmentMode=$true} + $cfg = @{Register=$true; ForceApplicationShutdown=$true; ForceUpdateFromAnyVersion=$true; DisableDevelopmentMode=$true} dir "$env:ProgramFiles\WindowsApps\MicrosoftWindows.Client.WebExperience*\AppxManifest.xml" -rec -ea 0 | Add-AppxPackage @cfg dir "$env:SystemRoot\SystemApps\Microsoft.Win32WebViewHost*\AppxManifest.xml" -rec -ea 0 | Add-AppxPackage @cfg kill -name explorer -ea 0; if ((get-process -name 'explorer' -ea 0) -eq $null) {start explorer} @@ -66,7 +66,7 @@ $D1=[uri].module.gettype('System.Diagnostics.Process')."GetM`ethods"(42) |where ## 3 shut edge & webview clone stuff down and gather install paths $shut = 'explorer','Widgets','widgetservice','msedgewebview2','MicrosoftEdge*','chredge','msedge','edge' -$shut+= 'msteams','msfamily','WebViewHost','Clipchamp' +$shut+= 'msteams','msfamily','WebViewHost','Clipchamp' cd $env:systemdrive; taskkill /im explorer.exe /f 2>&1 >''; foreach ($p in $shut) {kill -name $p -force -ea 0} prepare_edge ## clear win32 uninstall block @@ -93,15 +93,15 @@ $users = @('S-1-5-18'); if (test-path $store) {$users += $((dir $store -ea 0 |wh foreach ($choice in $remove_appx) { if ('' -eq $choice.Trim()) {continue} foreach ($appx in $($provisioned |where {$_.PackageName -like "*$choice*"})) { $next = !1; foreach ($no in $skip) {if ($appx.PackageName -like "*$no*") {$next = !0}} ; if ($next) {continue} - $PackageName = $appx.PackageName; $PackageFamilyName = ($appxpackage |where {$_.Name -eq $appx.DisplayName}).PackageFamilyName - ni "$store\Deprovisioned\$PackageFamilyName" -force >''; $PackageFamilyName + $PackageName = $appx.PackageName; $PackageFamilyName = ($appxpackage |where {$_.Name -eq $appx.DisplayName}).PackageFamilyName + ni "$store\Deprovisioned\$PackageFamilyName" -force >''; $PackageFamilyName foreach ($sid in $users) {ni "$store\EndOfLife\$sid\$PackageName" -force >''} ; $eol += $PackageName dism /online /set-nonremovableapppolicy /packagefamily:$PackageFamilyName /nonremovable:0 >'' remove-appxprovisionedpackage -packagename $PackageName -online -allusers >'' } foreach ($appx in $($appxpackage |where {$_.PackageFullName -like "*$choice*"})) { $next = !1; foreach ($no in $skip) {if ($appx.PackageFullName -like "*$no*") {$next = !0}} ; if ($next) {continue} - $PackageFullName = $appx.PackageFullName; + $PackageFullName = $appx.PackageFullName; ni "$store\Deprovisioned\$appx.PackageFamilyName" -force >''; $PackageFullName foreach ($sid in $users) {ni "$store\EndOfLife\$sid\$PackageFullName" -force >''} ; $eol += $PackageFullName dism /online /set-nonremovableapppolicy /packagefamily:$PackageFamilyName /nonremovable:0 >'' @@ -125,16 +125,16 @@ foreach ($PF in $env:ProgramFiles,${env:ProgramFiles(x86)}) { if (test-path "$PF if ($also_remove_webview -eq 1) { foreach ($hk in 'HKCU:','HKLM:') { foreach ($wow in '','\Wow6432Node') { ri "$hk\SOFTWARE${wow}\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge Update" -rec -force -ea 0 }} ri "$PF\Microsoft\EdgeUpdate" -rec -force -ea 0; Unregister-ScheduledTask -TaskName MicrosoftEdgeUpdate* -Confirm:$false -ea 0 - } + } }} $appdata = $([Environment]::GetFolderPath('ApplicationData')) ri "$appdata\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\Tombstones\Microsoft Edge.lnk" -force ri "$appdata\Microsoft\Internet Explorer\Quick Launch\Microsoft Edge.lnk" -force -## undo eol unblock trick to prevent latest cumulative update (LCU) failing +## undo eol unblock trick to prevent latest cumulative update (LCU) failing foreach ($sid in $users) { foreach ($PackageName in $eol) {ri "$store\EndOfLife\$sid\$PackageName" -force >''} } -## set (almost) useless policies to prevent unsolicited reinstalls +## set (almost) useless policies to prevent unsolicited reinstalls foreach ($p in 'HKLM:\SOFTWARE\Policies','HKLM:\SOFTWARE','HKLM:\SOFTWARE\WOW6432Node') { ni "$p\Microsoft\EdgeUpdate" -force >'' sp "$p\Microsoft\EdgeUpdate" 'InstallDefault' 0 -type Dword -force diff --git a/functions/private/ConvertTo-Icon.ps1 b/functions/private/ConvertTo-Icon.ps1 index 7a4d3e76..5ed7f5e7 100644 --- a/functions/private/ConvertTo-Icon.ps1 +++ b/functions/private/ConvertTo-Icon.ps1 @@ -1,27 +1,27 @@ -function ConvertTo-Icon { +function ConvertTo-Icon { <# - + .DESCRIPTION This function will convert PNG to ICO file .EXAMPLE ConvertTo-Icon -bitmapPath "$env:TEMP\cttlogo.png" -iconPath $iconPath #> - param( [Parameter(Mandatory=$true)] - $bitmapPath, + param( [Parameter(Mandatory=$true)] + $bitmapPath, $iconPath = "$env:temp\newicon.ico" - ) - - Add-Type -AssemblyName System.Drawing - - if (Test-Path $bitmapPath) { - $b = [System.Drawing.Bitmap]::FromFile($bitmapPath) - $icon = [System.Drawing.Icon]::FromHandle($b.GetHicon()) - $file = New-Object System.IO.FileStream($iconPath, 'OpenOrCreate') - $icon.Save($file) - $file.Close() - $icon.Dispose() - #explorer "/SELECT,$iconpath" - } - else { Write-Warning "$BitmapPath does not exist" } + ) + + Add-Type -AssemblyName System.Drawing + + if (Test-Path $bitmapPath) { + $b = [System.Drawing.Bitmap]::FromFile($bitmapPath) + $icon = [System.Drawing.Icon]::FromHandle($b.GetHicon()) + $file = New-Object System.IO.FileStream($iconPath, 'OpenOrCreate') + $icon.Save($file) + $file.Close() + $icon.Dispose() + #explorer "/SELECT,$iconpath" + } + else { Write-Warning "$BitmapPath does not exist" } } \ No newline at end of file diff --git a/functions/private/Copy-Files.ps1 b/functions/private/Copy-Files.ps1 index 4c054c81..447df38c 100644 --- a/functions/private/Copy-Files.ps1 +++ b/functions/private/Copy-Files.ps1 @@ -1,22 +1,22 @@ function Copy-Files { <# - + .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 ( - [string] $Path, - [string] $Destination, - [switch] $Recurse = $false, + [string] $Path, + [string] $Destination, + [switch] $Recurse = $false, [switch] $Force = $false ) - try { + try { $files = Get-ChildItem -Path $path -Recurse:$recurse Write-Host "Copy $($files.Count)(s) from $path to $destination" @@ -35,9 +35,9 @@ function Copy-Files { else { Write-Debug "Copy from $($file.FullName) to $($destination+$restpath)" - Copy-Item $file.FullName ($destination+$restpath) -ErrorAction SilentlyContinue -Force:$force + Copy-Item $file.FullName ($destination+$restpath) -ErrorAction SilentlyContinue -Force:$force Set-ItemProperty -Path ($destination+$restpath) -Name IsReadOnly -Value $false - } + } } Write-Progress -Activity "Copy Windows files" -Status "Ready" -Completed } diff --git a/functions/private/Get-LocalizedYesNo.ps1 b/functions/private/Get-LocalizedYesNo.ps1 index 723c0562..227bf8dd 100644 --- a/functions/private/Get-LocalizedYesNo.ps1 +++ b/functions/private/Get-LocalizedYesNo.ps1 @@ -1,17 +1,17 @@ function Get-LocalizedYesNo { <# .SYNOPSIS - This function runs choice.exe and captures its output to extract yes no in a localized Windows - + This function runs choice.exe and captures its output to extract yes no in a localized Windows + .DESCRIPTION The function retrieves the output of the command 'cmd /c "choice nul"' and converts the default output for Yes and No in the localized format, such as "Yes=, No=". - + .EXAMPLE $yesNoArray = Get-LocalizedYesNo Write-Host "Yes=$($yesNoArray[0]), No=$($yesNoArray[1])" #> - + # Run choice and capture its options as output # The output shows the options for Yes and No as "[Y,N]?" in the (partitially) localized format. # eg. English: [Y,N]? @@ -21,7 +21,7 @@ function Get-LocalizedYesNo { # Spanish: [S,N]? # Italian: [S,N]? # Russian: [Y,N]? - + $line = cmd /c "choice nul" $charactersArray = @() $regexPattern = '([a-zA-Z])' @@ -30,4 +30,5 @@ function Get-LocalizedYesNo { Write-Debug "According to takeown.exe local Yes is $charactersArray[0]" # Return the array of characters return $charactersArray + } \ No newline at end of file diff --git a/functions/private/Get-Oscdimg.ps1 b/functions/private/Get-Oscdimg.ps1 index 47a2eadd..38ea3b2c 100644 --- a/functions/private/Get-Oscdimg.ps1 +++ b/functions/private/Get-Oscdimg.ps1 @@ -1,13 +1,13 @@ -function Get-Oscdimg { +function Get-Oscdimg { <# - + .DESCRIPTION This function will download oscdimg file from github Release folders and put it into env:temp folder .EXAMPLE Get-Oscdimg #> - param( [Parameter(Mandatory=$true)] + param( [Parameter(Mandatory=$true)] [string]$oscdimgPath ) $oscdimgPath = "$env:TEMP\oscdimg.exe" @@ -24,4 +24,4 @@ function Get-Oscdimg { } else { Write-Host "Hashes do not match. File may be corrupted or tampered with." } -} +} diff --git a/functions/private/Get-TabXaml.ps1 b/functions/private/Get-TabXaml.ps1 index 3570af54..ea6d69f5 100644 --- a/functions/private/Get-TabXaml.ps1 +++ b/functions/private/Get-TabXaml.ps1 @@ -13,8 +13,8 @@ function Get-TabXaml { .EXAMPLE Get-TabXaml "applications" 3 #> - - + + param( [Parameter(Mandatory=$true)] $tabname, $columncount = 0 @@ -80,7 +80,7 @@ function Get-TabXaml { # Dot-source the Get-WPFObjectName function . .\functions\private\Get-WPFObjectName - + $categorycontent = $($category -replace '^.__', '') $categoryname = Get-WPFObjectName -type "Label" -name $categorycontent $blockXml += "