From 0bce9e26477df84362915569c4c53de4992f3e4f Mon Sep 17 00:00:00 2001 From: Chris Titus Date: Fri, 9 Aug 2024 10:15:20 -0500 Subject: [PATCH 01/23] pre-compile run --- .github/workflows/close-discussion-on-pr.yaml | 4 ++-- .github/workflows/compile-check.yaml | 2 +- .github/workflows/pre-release.yaml | 4 ++-- .github/workflows/remove-winutil.yaml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/close-discussion-on-pr.yaml b/.github/workflows/close-discussion-on-pr.yaml index 7ed0cc07..5ffeec42 100644 --- a/.github/workflows/close-discussion-on-pr.yaml +++ b/.github/workflows/close-discussion-on-pr.yaml @@ -35,7 +35,7 @@ jobs: -H "Accept: application/vnd.github.v3+json" \ -d '{"state": "closed"}' \ "https://api.github.com/repos/${{ github.repository }}/discussions/$discussion_id") - + if echo "$response" | jq -e '.id' > /dev/null; then echo "Successfully closed discussion #$discussion_id" else @@ -45,4 +45,4 @@ jobs: fi done shell: bash - continue-on-error: true \ No newline at end of file + continue-on-error: true diff --git a/.github/workflows/compile-check.yaml b/.github/workflows/compile-check.yaml index ff2d2fa1..394e558e 100644 --- a/.github/workflows/compile-check.yaml +++ b/.github/workflows/compile-check.yaml @@ -19,4 +19,4 @@ jobs: shell: pwsh run: | Set-ExecutionPolicy Bypass -Scope Process -Force; ./Compile.ps1 - continue-on-error: false # Directly fail the job on error, removing the need for a separate check \ No newline at end of file + continue-on-error: false # Directly fail the job on error, removing the need for a separate check diff --git a/.github/workflows/pre-release.yaml b/.github/workflows/pre-release.yaml index 75f69e2f..d6bf6912 100644 --- a/.github/workflows/pre-release.yaml +++ b/.github/workflows/pre-release.yaml @@ -67,13 +67,13 @@ jobs: run: | $signature = Get-AuthenticodeSignature -FilePath ./winutil.ps1 if ($signature.Status -ne 'Valid') { throw "Code signing failed" } - + - name: Upload winutil.ps1 as artifact uses: actions/upload-artifact@v4 with: name: winutil path: ./winutil.ps1 - + - name: Create and Upload Release id: create_release uses: softprops/action-gh-release@v2 diff --git a/.github/workflows/remove-winutil.yaml b/.github/workflows/remove-winutil.yaml index 69396a3e..5dedbe93 100644 --- a/.github/workflows/remove-winutil.yaml +++ b/.github/workflows/remove-winutil.yaml @@ -31,4 +31,4 @@ jobs: git commit -m "Delete winutil.ps1 as it is not allowed" git push origin HEAD:${{ github.ref }} env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 5994105fba1e49e8651ce4f2ca27a609ea433536 Mon Sep 17 00:00:00 2001 From: ChrisTitusTech Date: Fri, 9 Aug 2024 15:31:32 +0000 Subject: [PATCH 02/23] =?UTF-8?q?Deploying=20to=20main=20from=20@=20ChrisT?= =?UTF-8?q?itusTech/winutil@0bce9e26477df84362915569c4c53de4992f3e4f=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 82549f10..c4cfa6ec 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ If you have Issues, refer to [Known Issues](https://christitustech.github.io/win These are the sponsors that help keep this project alive with monthly contributions. -Gregory NavasarkianYusuke SaitoTriHyderaMark AmosJason A. DiegmuellerwyattOwenStefanthaddlPaulDave JonesAnthony MendezMichael Wozniak +Gregory NavasarkianYusuke SaitoTriHyderaMark AmosJason A. DiegmuellerwyattStefanthaddlPaulDave JonesAnthony MendezMichael WozniakxPandaku ## 🏅 Thanks to all Contributors Thanks a lot for spending your time helping Winutil grow. Thanks a lot! Keep rocking 🍻. From 41ac93d09ae79bb761964b9cdb6ed7f4a0908fe3 Mon Sep 17 00:00:00 2001 From: CodingWonders <101426328+CodingWonders@users.noreply.github.com> Date: Mon, 12 Aug 2024 22:03:38 +0200 Subject: [PATCH 03/23] Add quotes to paths (#2552) Fixes reported issues about paths with spaces --- functions/private/Invoke-MicroWin-Helper.ps1 | 6 +++--- functions/public/Invoke-WPFGetIso.ps1 | 8 ++++---- functions/public/Invoke-WPFMicrowin.ps1 | 12 ++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/functions/private/Invoke-MicroWin-Helper.ps1 b/functions/private/Invoke-MicroWin-Helper.ps1 index d0cd1c9e..ece18de9 100644 --- a/functions/private/Invoke-MicroWin-Helper.ps1 +++ b/functions/private/Invoke-MicroWin-Helper.ps1 @@ -157,7 +157,7 @@ function Remove-ProvisionedPackages([switch]$keepSecurity = $false) { $status = "Removing Provisioned $($appx.PackageName)" Write-Progress -Activity "Removing Provisioned Apps" -Status $status -PercentComplete ($counter++/$appxProvisionedPackages.Count*100) try { - Remove-AppxProvisionedPackage -Path $scratchDir -PackageName $appx.PackageName -ErrorAction SilentlyContinue + Remove-AppxProvisionedPackage -Path "$scratchDir" -PackageName $appx.PackageName -ErrorAction SilentlyContinue } catch { Write-Host "Application $($appx.PackageName) could not be removed" continue @@ -175,9 +175,9 @@ function Copy-ToUSB([string]$fileToCopy) { $destinationPath = "$($volume.DriveLetter):\" #Copy-Item -Path $fileToCopy -Destination $destinationPath -Force # Get the total size of the file - $totalSize = (Get-Item $fileToCopy).length + $totalSize = (Get-Item "$fileToCopy").length - Copy-Item -Path $fileToCopy -Destination $destinationPath -Verbose -Force -Recurse -Container -PassThru | + Copy-Item -Path "$fileToCopy" -Destination "$destinationPath" -Verbose -Force -Recurse -Container -PassThru | ForEach-Object { # Calculate the percentage completed $completed = ($_.BytesTransferred / $totalSize) * 100 diff --git a/functions/public/Invoke-WPFGetIso.ps1 b/functions/public/Invoke-WPFGetIso.ps1 index 2db534c7..9a0b7455 100644 --- a/functions/public/Invoke-WPFGetIso.ps1 +++ b/functions/public/Invoke-WPFGetIso.ps1 @@ -76,7 +76,7 @@ function Invoke-WPFGetIso { } Write-Host "File path $($filePath)" - if (-not (Test-Path -Path $filePath -PathType Leaf)) { + if (-not (Test-Path -Path "$filePath" -PathType Leaf)) { $msg = "File you've chosen doesn't exist" [System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Error) return @@ -85,7 +85,7 @@ function Invoke-WPFGetIso { Set-WinUtilTaskbaritem -state "Indeterminate" -overlay "logo" # Detect the file size of the ISO and compare it with the free space of the system drive - $isoSize = (Get-Item -Path $filePath).Length + $isoSize = (Get-Item -Path "$filePath").Length Write-Debug "Size of ISO file: $($isoSize) bytes" # Use this procedure to get the free space of the drive depending on where the user profile folder is stored. # This is done to guarantee a dynamic solution, as the installation drive may be mounted to a letter different than C @@ -122,7 +122,7 @@ function Invoke-WPFGetIso { # there is probably a better way of doing this, I don't have time to figure this out $sync.MicrowinIsoDrive.Text = $driveLetter - $mountedISOPath = (Split-Path -Path $filePath) + $mountedISOPath = (Split-Path -Path "$filePath") if ($sync.MicrowinScratchDirBox.Text.Trim() -eq "Scratch") { $sync.MicrowinScratchDirBox.Text ="" } @@ -186,7 +186,7 @@ function Invoke-WPFGetIso { $wimFile = "$mountDir\sources\install.wim" Write-Host "Getting image information $wimFile" - if ((-not (Test-Path -Path $wimFile -PathType Leaf)) -and (-not (Test-Path -Path $wimFile.Replace(".wim", ".esd").Trim() -PathType Leaf))) { + if ((-not (Test-Path -Path "$wimFile" -PathType Leaf)) -and (-not (Test-Path -Path "$($wimFile.Replace(".wim", ".esd").Trim())" -PathType Leaf))) { $msg = "Neither install.wim nor install.esd exist in the image, this could happen if you use unofficial Windows images. Please don't use shady images from the internet, use only official images. Here are instructions how to download ISO images if the Microsoft website is not showing the link to download and ISO. https://www.techrepublic.com/article/how-to-download-a-windows-10-iso-file-without-using-the-media-creation-tool/" Write-Host $msg [System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Error) diff --git a/functions/public/Invoke-WPFMicrowin.ps1 b/functions/public/Invoke-WPFMicrowin.ps1 index 23a12fa2..4e729cd8 100644 --- a/functions/public/Invoke-WPFMicrowin.ps1 +++ b/functions/public/Invoke-WPFMicrowin.ps1 @@ -63,11 +63,11 @@ public class PowerManagement { $scratchDir = $sync.MicrowinScratchDir.Text # Detect if the Windows image is an ESD file and convert it to WIM - if (-not (Test-Path -Path $mountDir\sources\install.wim -PathType Leaf) -and (Test-Path -Path $mountDir\sources\install.esd -PathType Leaf)) { + if (-not (Test-Path -Path "$mountDir\sources\install.wim" -PathType Leaf) -and (Test-Path -Path "$mountDir\sources\install.esd" -PathType Leaf)) { Write-Host "Exporting Windows image to a WIM file, keeping the index we want to work on. This can take several minutes, depending on the performance of your computer..." Export-WindowsImage -SourceImagePath $mountDir\sources\install.esd -SourceIndex $index -DestinationImagePath $mountDir\sources\install.wim -CompressionType "Max" if ($?) { - Remove-Item -Path $mountDir\sources\install.esd -Force + Remove-Item -Path "$mountDir\sources\install.esd" -Force # Since we've already exported the image index we wanted, switch to the first one $index = 1 } else { @@ -116,7 +116,7 @@ public class PowerManagement { if (Test-Path "$env:TEMP\DRV_EXPORT") { Remove-Item "$env:TEMP\DRV_EXPORT" -Recurse -Force } - if (($injectDrivers -and (Test-Path $sync.MicrowinDriverLocation.Text))) { + if (($injectDrivers -and (Test-Path "$($sync.MicrowinDriverLocation.Text)"))) { Write-Host "Using specified driver source..." dism /english /online /export-driver /destination="$($sync.MicrowinDriverLocation.Text)" | Out-Host if ($?) { @@ -341,7 +341,7 @@ public class PowerManagement { Write-Host "Cleanup complete." Write-Host "Unmounting image..." - Dismount-WindowsImage -Path $scratchDir -Save + Dismount-WindowsImage -Path "$scratchDir" -Save } try { @@ -403,7 +403,7 @@ public class PowerManagement { reg unload HKLM\zSYSTEM Write-Host "Unmounting image..." - Dismount-WindowsImage -Path $scratchDir -Save + Dismount-WindowsImage -Path "$scratchDir" -Save Write-Host "Creating ISO image" @@ -417,7 +417,7 @@ public class PowerManagement { Write-Host "[INFO] Using oscdimg.exe from: $oscdimgPath" - $oscdimgProc = Start-Process -FilePath "$oscdimgPath" -ArgumentList "-m -o -u2 -udfver102 -bootdata:2#p0,e,b$mountDir\boot\etfsboot.com#pEF,e,b$mountDir\efi\microsoft\boot\efisys.bin `"$mountDir`" `"$($SaveDialog.FileName)`"" -Wait -PassThru -NoNewWindow + $oscdimgProc = Start-Process -FilePath "$oscdimgPath" -ArgumentList "-m -o -u2 -udfver102 -bootdata:2#p0,e,b`"$mountDir\boot\etfsboot.com`"#pEF,e,b`"$mountDir\efi\microsoft\boot\efisys.bin`" `"$mountDir`" `"$($SaveDialog.FileName)`"" -Wait -PassThru -NoNewWindow $LASTEXITCODE = $oscdimgProc.ExitCode From 0919e78693fe5ff4dcc10d0a8fe99625bd20b68e Mon Sep 17 00:00:00 2001 From: Psyi Rius <99079175+psyirius@users.noreply.github.com> Date: Mon, 12 Aug 2024 15:10:07 -0700 Subject: [PATCH 04/23] microwin remove expedited apps (#2555) --- functions/public/Invoke-WPFMicrowin.ps1 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/functions/public/Invoke-WPFMicrowin.ps1 b/functions/public/Invoke-WPFMicrowin.ps1 index 4e729cd8..4b69fde6 100644 --- a/functions/public/Invoke-WPFMicrowin.ps1 +++ b/functions/public/Invoke-WPFMicrowin.ps1 @@ -303,6 +303,22 @@ public class PowerManagement { } } + # Prevent Windows Update Installing so called Expedited Apps + @( + 'EdgeUpdate', + 'DevHomeUpdate', + 'OutlookUpdate', + 'CrossDeviceUpdate' + ) | ForEach-Object { + Write-Host "Removing Windows Expedited App: $_" + + # Copied here After Installation (Online) + # reg delete "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Orchestrator\UScheduler\$_" /f | Out-Null + + # When in Offline Image + reg delete "HKLM\zSOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\$_" /f | Out-Null + } + reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Search" /v "SearchboxTaskbarMode" /t REG_DWORD /d 0 /f Write-Host "Setting all services to start manually" reg add "HKLM\zSOFTWARE\CurrentControlSet\Services" /v Start /t REG_DWORD /d 3 /f From 5d7d121e1fa467ff398363403cbdb7f5a247e14c Mon Sep 17 00:00:00 2001 From: MyDrift Date: Tue, 13 Aug 2024 00:10:44 +0200 Subject: [PATCH 05/23] fix get state & add disable emoticon (#2554) --- functions/private/Get-WinUtilToggleStatus.ps1 | 5 +++-- functions/private/Invoke-WinUtilDetailedBSoD.ps1 | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/functions/private/Get-WinUtilToggleStatus.ps1 b/functions/private/Get-WinUtilToggleStatus.ps1 index 019978a4..ea349779 100644 --- a/functions/private/Get-WinUtilToggleStatus.ps1 +++ b/functions/private/Get-WinUtilToggleStatus.ps1 @@ -140,8 +140,9 @@ Function Get-WinUtilToggleStatus { } } if ($ToggleSwitch -eq "WPFToggleDetailedBSoD") { - $DetailedBSoD = (Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl').DisplayParameters - if($DetailedBSoD -eq 0) { + $DetailedBSoD1 = (Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl').DisplayParameters + $DetailedBSoD2 = (Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl').DisableEmoticon + if (($DetailedBSoD1 -eq 0) -or ($DetailedBSoD2 -eq 0) -or !$DetailedBSoD1 -or !$DetailedBSoD2) { return $false } else { return $true diff --git a/functions/private/Invoke-WinUtilDetailedBSoD.ps1 b/functions/private/Invoke-WinUtilDetailedBSoD.ps1 index 21b0a84f..efe4f624 100644 --- a/functions/private/Invoke-WinUtilDetailedBSoD.ps1 +++ b/functions/private/Invoke-WinUtilDetailedBSoD.ps1 @@ -18,6 +18,10 @@ Function Invoke-WinUtilDetailedBSoD { } $Path = "HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl" + $dwords = ("DisplayParameters", "DisableEmoticon") + foreach ($name in $dwords) { + Set-ItemProperty -Path $Path -Name $name -Value $value + } Set-ItemProperty -Path $Path -Name DisplayParameters -Value $value } catch [System.Security.SecurityException] { Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception" From e90156adb91948bc77bcbb4f13bd7d2946839273 Mon Sep 17 00:00:00 2001 From: Psyi Rius <99079175+psyirius@users.noreply.github.com> Date: Mon, 12 Aug 2024 15:12:53 -0700 Subject: [PATCH 06/23] undo dism add-edge (#2553) --- functions/public/Invoke-WPFMicrowin.ps1 | 79 ++++++++++++++++++------- 1 file changed, 56 insertions(+), 23 deletions(-) diff --git a/functions/public/Invoke-WPFMicrowin.ps1 b/functions/public/Invoke-WPFMicrowin.ps1 index 4b69fde6..b0f34ad2 100644 --- a/functions/public/Invoke-WPFMicrowin.ps1 +++ b/functions/public/Invoke-WPFMicrowin.ps1 @@ -174,12 +174,13 @@ public class PowerManagement { Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Program Files\Windows Defender" -Directory Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Program Files (x86)\Windows Defender" } - if (!$keepEdge) { - Write-Host "Removing Edge" - Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Program Files (x86)\Microsoft" -mask "*edge*" -Directory - Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Program Files\Microsoft" -mask "*edge*" -Directory - Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\SystemApps" -mask "*edge*" -Directory - } + # if (!$keepEdge) { + # # this is destructive and might result in touching SystemApps is not recommended unless you going complete rogue on trimming edge and telemetry + # Write-Host "Removing Edge" + # Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Program Files (x86)\Microsoft" -mask "*edge*" -Directory + # Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Program Files\Microsoft" -mask "*edge*" -Directory + # Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\SystemApps" -mask "*edge*" -Directory + # } Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\DiagTrack" -Directory Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\InboxApps" -Directory @@ -283,24 +284,56 @@ public class PowerManagement { reg add "HKLM\zSYSTEM\Setup\MoSetup" /v "AllowUpgradesWithUnsupportedTPMOrCPU" /t REG_DWORD /d 1 /f if (!$keepEdge) { - Write-Host "Removing Edge icon from taskbar" - reg delete "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Taskband" /v "Favorites" /f >$null 2>&1 - reg delete "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Taskband" /v "FavoritesChanges" /f >$null 2>&1 - reg delete "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Taskband" /v "Pinned" /f >$null 2>&1 - reg delete "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Taskband" /v "LayoutCycle" /f >$null 2>&1 - Write-Host "Edge icon removed from taskbar" - if (Test-Path "HKLM:\zSOFTWARE\WOW6432Node") { - # Remove leftovers of 64-bit installations - # --- - # Remove registry values first... - reg delete "HKLM\zSOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge" /va /f > $null 2>&1 - reg delete "HKLM\zSOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge Update" /va /f > $null 2>&1 - reg delete "HKLM\zSOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft EdgeWebView" /va /f > $null 2>&1 - # ...then the registry keys - reg delete "HKLM\zSOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge" /f > $null 2>&1 - reg delete "HKLM\zSOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge Update" /f > $null 2>&1 - reg delete "HKLM\zSOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft EdgeWebView" /f > $null 2>&1 + # Undo changes made by -> Dism Add-Edge Edge.wim (Trust Me: this is the non-destructive way to unintegrate Edge) + + Write-Host "Removing Edge" + + # Microsoft Edge + reg delete "HKLM\zSOFTWARE\Microsoft\Active Setup\Installed Components\{9459C573-B17A-45AE-9F64-1857B5D58CEE}" /f | Out-Null + + reg delete "HKLM\zSOFTWARE\Wow6432Node\Microsoft\EdgeUpdate\Clients\{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" /f | Out-Null + reg delete "HKLM\zSOFTWARE\Wow6432Node\Microsoft\EdgeUpdate\ClientState\{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" /f | Out-Null + + reg delete "HKLM\zSOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge" /f | Out-Null + + if (Test-Path "$scratchDir\Program Files (x86)\Microsoft\Edge" -Type Container) { + Remove-Item "$scratchDir\Program Files (x86)\Microsoft\Edge" -Recurse -Force | Out-Null } + + # Extra + reg delete "HKLM\zSOFTWARE\Microsoft\MicrosoftEdge" /f | Out-Null + + # Microsoft EdgeWebView + reg delete "HKLM\zSOFTWARE\Wow6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" /f | Out-Null + reg delete "HKLM\zSOFTWARE\Wow6432Node\Microsoft\EdgeUpdate\ClientState\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" /f | Out-Null + + reg delete "HKLM\zSOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft EdgeWebView" /f | Out-Null + + if (Test-Path "$scratchDir\Program Files (x86)\Microsoft\EdgeWebView" -Type Container) { + Remove-Item "$scratchDir\Program Files (x86)\Microsoft\EdgeWebView" -Recurse -Force | Out-Null + } + + # Edge Core + if (Test-Path "$scratchDir\Program Files (x86)\Microsoft\EdgeCore" -Type Container) { + Remove-Item "$scratchDir\Program Files (x86)\Microsoft\EdgeCore" -Recurse -Force | Out-Null + } + + # Microsoft Edge Update + reg delete "HKLM\zSOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\MicrosoftEdgeUpdate.exe" /f | Out-Null + + reg delete "HKLM\zSOFTWARE\Wow6432Node\Microsoft\EdgeUpdate" /f | Out-Null + reg delete "HKLM\zSOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge Update" /f | Out-Null + + # Microsoft Edge Update :: Services + reg delete "HKLM\zSYSTEM\ControlSet001\Services\edgeupdate" /f | Out-Null + reg delete "HKLM\zSYSTEM\ControlSet001\Services\edgeupdatem" /f | Out-Null + + if (Test-Path "$scratchDir\Program Files (x86)\Microsoft\EdgeUpdate" -Type Container) { + Remove-Item "$scratchDir\Program Files (x86)\Microsoft\EdgeUpdate" -Recurse -Force | Out-Null + } + + # Prevent EdgeChromium from Installing in the future + reg add "HKLM\zSOFTWARE\Microsoft\EdgeUpdate" /v "DoNotUpdateToEdgeWithChromium" /t REG_DWORD /d "1" /f | Out-Null } # Prevent Windows Update Installing so called Expedited Apps From 8c4dc82d31ac3996c8f63b5f47dcd7db1742484c Mon Sep 17 00:00:00 2001 From: Chris Titus Tech Date: Tue, 13 Aug 2024 11:07:52 -0500 Subject: [PATCH 07/23] MicroWin Improvements autosetup --- autounattend.xml | 442 ++++++++++++++++++ ....ps1 => Invoke-WinUtilMicroWin-Helper.ps1} | 247 +++++++++- functions/public/Invoke-WPFMicrowin.ps1 | 2 +- 3 files changed, 683 insertions(+), 8 deletions(-) create mode 100644 autounattend.xml rename functions/private/{Invoke-MicroWin-Helper.ps1 => Invoke-WinUtilMicroWin-Helper.ps1} (61%) diff --git a/autounattend.xml b/autounattend.xml new file mode 100644 index 00000000..c3a2f213 --- /dev/null +++ b/autounattend.xml @@ -0,0 +1,442 @@ + + + + + + + + en-US + + 0409:00000409 + en-US + en-US + en-US + + + + + VK7JG-NPHTM-C97JM-9MPGT-3V66T + + true + + + + 1 + reg.exe add "HKLM\SYSTEM\Setup\LabConfig" /v BypassTPMCheck /t REG_DWORD /d 1 /f + + + 2 + reg.exe add "HKLM\SYSTEM\Setup\LabConfig" /v BypassSecureBootCheck /t REG_DWORD /d 1 /f + + + 3 + reg.exe add "HKLM\SYSTEM\Setup\LabConfig" /v BypassRAMCheck /t REG_DWORD /d 1 /f + + + + + + + + + + 1 + reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OOBE" /v BypassNRO /t REG_DWORD /d 1 /f + + + 2 + reg.exe load "HKU\DefaultUser" "C:\Users\Default\NTUSER.DAT" + + + 3 + reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\Runonce" /v "UninstallCopilot" /t REG_SZ /d "powershell.exe -NoProfile -Command \"Get-AppxPackage -Name 'Microsoft.Windows.Ai.Copilot.Provider' | Remove-AppxPackage;\"" /f + + + 4 + reg.exe add "HKU\DefaultUser\Software\Policies\Microsoft\Windows\WindowsCopilot" /v TurnOffWindowsCopilot /t REG_DWORD /d 1 /f + + + 5 + reg.exe unload "HKU\DefaultUser" + + + 6 + reg.exe delete "HKLM\SOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\DevHomeUpdate" /f + + + 7 + reg.exe load "HKU\DefaultUser" "C:\Users\Default\NTUSER.DAT" + + + 8 + reg.exe add "HKU\DefaultUser\Software\Microsoft\Notepad" /v ShowStoreBanner /t REG_DWORD /d 0 /f + + + 9 + reg.exe unload "HKU\DefaultUser" + + + 10 + cmd.exe /c "del "C:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk"" + + + 11 + cmd.exe /c "del "C:\Windows\System32\OneDriveSetup.exe"" + + + 12 + cmd.exe /c "del "C:\Windows\SysWOW64\OneDriveSetup.exe"" + + + 13 + reg.exe load "HKU\DefaultUser" "C:\Users\Default\NTUSER.DAT" + + + 14 + reg.exe delete "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\Run" /v OneDriveSetup /f + + + 15 + reg.exe unload "HKU\DefaultUser" + + + 16 + reg.exe delete "HKLM\SOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\OutlookUpdate" /f + + + 17 + reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Communications" /v ConfigureChatAutoInstall /t REG_DWORD /d 0 /f + + + 18 + powershell.exe -NoProfile -Command "$xml = [xml]::new(); $xml.Load('C:\Windows\Panther\unattend.xml'); $sb = [scriptblock]::Create( $xml.unattend.Extensions.ExtractScript ); Invoke-Command -ScriptBlock $sb -ArgumentList $xml;" + + + 19 + powershell.exe -NoProfile -Command "Get-Content -LiteralPath 'C:\Windows\Temp\remove-packages.ps1' -Raw | Invoke-Expression;" + + + 20 + powershell.exe -NoProfile -Command "Get-Content -LiteralPath 'C:\Windows\Temp\remove-caps.ps1' -Raw | Invoke-Expression;" + + + 21 + reg.exe add "HKLM\SOFTWARE\Microsoft\PolicyManager\current\device\Start" /v ConfigureStartPins /t REG_SZ /d "{ \"pinnedList\": [] }" /f + + + 22 + reg.exe add "HKLM\SOFTWARE\Microsoft\PolicyManager\current\device\Start" /v ConfigureStartPins_ProviderSet /t REG_DWORD /d 1 /f + + + 23 + reg.exe add "HKLM\SOFTWARE\Microsoft\PolicyManager\current\device\Start" /v ConfigureStartPins_WinningProvider /t REG_SZ /d B5292708-1619-419B-9923-E5D9F3925E71 /f + + + 24 + reg.exe add "HKLM\SOFTWARE\Microsoft\PolicyManager\providers\B5292708-1619-419B-9923-E5D9F3925E71\default\Device\Start" /v ConfigureStartPins /t REG_SZ /d "{ \"pinnedList\": [] }" /f + + + 25 + reg.exe add "HKLM\SOFTWARE\Microsoft\PolicyManager\providers\B5292708-1619-419B-9923-E5D9F3925E71\default\Device\Start" /v ConfigureStartPins_LastWrite /t REG_DWORD /d 1 /f + + + 26 + net.exe accounts /maxpwage:UNLIMITED + + + 27 + reg.exe add "HKLM\SYSTEM\CurrentControlSet\Control\FileSystem" /v LongPathsEnabled /t REG_DWORD /d 1 /f + + + 28 + reg.exe add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Power" /v HiberbootEnabled /t REG_DWORD /d 0 /f + + + 29 + reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Dsh" /v AllowNewsAndInterests /t REG_DWORD /d 0 /f + + + 30 + reg.exe load "HKU\DefaultUser" "C:\Users\Default\NTUSER.DAT" + + + 31 + reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "ContentDeliveryAllowed" /t REG_DWORD /d 0 /f + + + 32 + reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "FeatureManagementEnabled" /t REG_DWORD /d 0 /f + + + 33 + reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "OEMPreInstalledAppsEnabled" /t REG_DWORD /d 0 /f + + + 34 + reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "PreInstalledAppsEnabled" /t REG_DWORD /d 0 /f + + + 35 + reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "PreInstalledAppsEverEnabled" /t REG_DWORD /d 0 /f + + + 36 + reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SilentInstalledAppsEnabled" /t REG_DWORD /d 0 /f + + + 37 + reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SoftLandingEnabled" /t REG_DWORD /d 0 /f + + + 38 + reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContentEnabled" /t REG_DWORD /d 0 /f + + + 39 + reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContent-310093Enabled" /t REG_DWORD /d 0 /f + + + 40 + reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContent-338387Enabled" /t REG_DWORD /d 0 /f + + + 41 + reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContent-338388Enabled" /t REG_DWORD /d 0 /f + + + 42 + reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContent-338389Enabled" /t REG_DWORD /d 0 /f + + + 43 + reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContent-338393Enabled" /t REG_DWORD /d 0 /f + + + 44 + reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContent-353698Enabled" /t REG_DWORD /d 0 /f + + + 45 + reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SystemPaneSuggestionsEnabled" /t REG_DWORD /d 0 /f + + + 46 + reg.exe unload "HKU\DefaultUser" + + + 47 + reg.exe add "HKLM\Software\Policies\Microsoft\Windows\CloudContent" /v "DisableWindowsConsumerFeatures" /t REG_DWORD /d 0 /f + + + 48 + reg.exe add "HKLM\SYSTEM\CurrentControlSet\Control\BitLocker" /v "PreventDeviceEncryption" /t REG_DWORD /d 1 /f + + + 49 + reg.exe load "HKU\DefaultUser" "C:\Users\Default\NTUSER.DAT" + + + 50 + reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\Runonce" /v "ClassicContextMenu" /t REG_SZ /d "reg.exe add \"HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32\" /ve /f" /f + + + 51 + reg.exe unload "HKU\DefaultUser" + + + + + + + + + 0409:00000409 + en-US + en-US + en-US + + + + + + User + Administrators + + + true</PlainText> + </Password> + </LocalAccount> + </LocalAccounts> + </UserAccounts> + <AutoLogon> + <Username>User</Username> + <Enabled>true</Enabled> + <LogonCount>1</LogonCount> + <Password> + <Value></Value> + <PlainText>true</PlainText> + </Password> + </AutoLogon> + <OOBE> + <ProtectYourPC>3</ProtectYourPC> + <HideEULAPage>true</HideEULAPage> + <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE> + </OOBE> + <FirstLogonCommands> + <SynchronousCommand wcm:action="add"> + <Order>1</Order> + <CommandLine>reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoLogonCount /t REG_DWORD /d 0 /f</CommandLine> + </SynchronousCommand> + </FirstLogonCommands> + </component> + </settings> + <Extensions xmlns="https://schneegans.de/windows/unattend-generator/"> + <ExtractScript> +param( + [xml] $Document +); + +$scriptsDir = 'C:\Windows\Setup\Scripts\'; +foreach( $file in $Document.unattend.Extensions.File ) { + $path = [System.Environment]::ExpandEnvironmentVariables( + $file.GetAttribute( 'path' ) + ); + if( $path.StartsWith( $scriptsDir ) ) { + mkdir -Path $scriptsDir -ErrorAction 'SilentlyContinue'; + } + $encoding = switch( [System.IO.Path]::GetExtension( $path ) ) { + { $_ -in '.ps1', '.xml' } { [System.Text.Encoding]::UTF8; } + { $_ -in '.reg', '.vbs', '.js' } { [System.Text.UnicodeEncoding]::new( $false, $true ); } + default { [System.Text.Encoding]::Default; } + }; + [System.IO.File]::WriteAllBytes( $path, ( $encoding.GetPreamble() + $encoding.GetBytes( $file.InnerText.Trim() ) ) ); +} + </ExtractScript> + <File path="C:\Windows\Temp\remove-packages.ps1"> +$selectors = @( + 'Microsoft.Microsoft3DViewer'; + 'Microsoft.BingSearch'; + 'Microsoft.WindowsCamera'; + 'Clipchamp.Clipchamp'; + 'Microsoft.WindowsAlarms'; + 'Microsoft.549981C3F5F10'; + 'Microsoft.Windows.DevHome'; + 'MicrosoftCorporationII.MicrosoftFamily'; + 'Microsoft.WindowsFeedbackHub'; + 'Microsoft.GetHelp'; + 'Microsoft.Getstarted'; + 'microsoft.windowscommunicationsapps'; + 'Microsoft.WindowsMaps'; + 'Microsoft.BingNews'; + 'Microsoft.WindowsNotepad'; + 'Microsoft.MicrosoftOfficeHub'; + 'Microsoft.Office.OneNote'; + 'Microsoft.OutlookForWindows'; + 'Microsoft.MSPaint'; + 'Microsoft.People'; + 'Microsoft.PowerAutomateDesktop'; + 'MicrosoftCorporationII.QuickAssist'; + 'Microsoft.SkypeApp'; + 'Microsoft.MicrosoftSolitaireCollection'; + 'Microsoft.MicrosoftStickyNotes'; + 'MSTeams'; + 'Microsoft.Todos'; + 'Microsoft.WindowsSoundRecorder'; + 'Microsoft.BingWeather'; + 'Microsoft.ZuneMusic'; + 'Microsoft.ZuneVideo'; +); +$getCommand = { Get-AppxProvisionedPackage -Online; }; +$filterCommand = { $_.DisplayName -eq $selector; }; +$removeCommand = { + [CmdletBinding()] + param( + [Parameter( Mandatory, ValueFromPipeline )] + $InputObject + ); + process { + $InputObject | Remove-AppxProvisionedPackage -AllUsers -Online -ErrorAction 'Continue'; + } +}; +$type = 'Package'; +$logfile = 'C:\Windows\Temp\remove-packages.log'; +&amp; { + $installed = &amp; $getCommand; + foreach( $selector in $selectors ) { + $result = [ordered] @{ + Selector = $selector; + }; + $found = $installed | Where-Object -FilterScript $filterCommand; + if( $found ) { + $result.Output = $found | &amp; $removeCommand; + if( $? ) { + $result.Message = "$type removed."; + } else { + $result.Message = "$type not removed."; + $result.Error = $Error[0]; + } + } else { + $result.Message = "$type not installed."; + } + $result | ConvertTo-Json -Depth 3 -Compress; + } +} *&gt;&amp;1 &gt;&gt; $logfile; + </File> + <File path="C:\Windows\Temp\remove-caps.ps1"> +$selectors = @( + 'Browser.InternetExplorer'; + 'MathRecognizer'; + 'OpenSSH.Client'; + 'App.Support.QuickAssist'; + 'App.StepsRecorder'; + 'Media.WindowsMediaPlayer'; + 'Microsoft.Windows.WordPad'; +); +$getCommand = { Get-WindowsCapability -Online; }; +$filterCommand = { ($_.Name -split '~')[0] -eq $selector; }; +$removeCommand = { + [CmdletBinding()] + param( + [Parameter( Mandatory, ValueFromPipeline )] + $InputObject + ); + process { + $InputObject | Remove-WindowsCapability -Online -ErrorAction 'Continue'; + } +}; +$type = 'Capability'; +$logfile = 'C:\Windows\Temp\remove-caps.log'; +&amp; { + $installed = &amp; $getCommand; + foreach( $selector in $selectors ) { + $result = [ordered] @{ + Selector = $selector; + }; + $found = $installed | Where-Object -FilterScript $filterCommand; + if( $found ) { + $result.Output = $found | &amp; $removeCommand; + if( $? ) { + $result.Message = "$type removed."; + } else { + $result.Message = "$type not removed."; + $result.Error = $Error[0]; + } + } else { + $result.Message = "$type not installed."; + } + $result | ConvertTo-Json -Depth 3 -Compress; + } +} *&gt;&amp;1 &gt;&gt; $logfile; + </File> + <File path="C:\Users\Default\AppData\Local\Microsoft\Windows\Shell\LayoutModification.xml"><![CDATA[ +<LayoutModificationTemplate Version="1" xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification"> + <LayoutOptions StartTileGroupCellWidth="6" /> + <DefaultLayoutOverride> + <StartLayoutCollection> + <StartLayout GroupCellWidth="6" xmlns="http://schemas.microsoft.com/Start/2014/FullDefaultLayout" /> + </StartLayoutCollection> + </DefaultLayoutOverride> +</LayoutModificationTemplate> + ]]></File> + </Extensions> +</unattend> diff --git a/functions/private/Invoke-MicroWin-Helper.ps1 b/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 similarity index 61% rename from functions/private/Invoke-MicroWin-Helper.ps1 rename to functions/private/Invoke-WinUtilMicroWin-Helper.ps1 index ece18de9..15b42582 100644 --- a/functions/private/Invoke-MicroWin-Helper.ps1 +++ b/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 @@ -313,10 +313,31 @@ function New-Unattend { </settings> <settings pass="oobeSystem"> <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <UserAccounts> + <LocalAccounts> + <LocalAccount wcm:action="add"> + <Name>User</Name> + <Group>Administrators</Group> + <Password> + <Value></Value> + <PlainText>true</PlainText> + </Password> + </LocalAccount> + </LocalAccounts> + </UserAccounts> + <AutoLogon> + <Username>User</Username> + <Enabled>true</Enabled> + <LogonCount>1</LogonCount> + <Password> + <Value></Value> + <PlainText>true</PlainText> + </Password> + </AutoLogon> <OOBE> - <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen> - <SkipUserOOBE>false</SkipUserOOBE> - <SkipMachineOOBE>false</SkipMachineOOBE> + <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen> + <SkipUserOOBE>true</SkipUserOOBE> + <SkipMachineOOBE>true</SkipMachineOOBE> <HideOnlineAccountScreens>true</HideOnlineAccountScreens> <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE> <HideEULAPage>true</HideEULAPage> @@ -325,14 +346,18 @@ function New-Unattend { <FirstLogonCommands> <SynchronousCommand wcm:action="add"> <Order>1</Order> - <CommandLine>cmd.exe /c echo 23&gt;c:\windows\csup.txt</CommandLine> + <CommandLine>reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoLogonCount /t REG_DWORD /d 0 /f</CommandLine> </SynchronousCommand> <SynchronousCommand wcm:action="add"> <Order>2</Order> - <CommandLine>CMD /C echo GG&gt;C:\Windows\LogOobeSystem.txt</CommandLine> + <CommandLine>cmd.exe /c echo 23&gt;c:\windows\csup.txt</CommandLine> </SynchronousCommand> <SynchronousCommand wcm:action="add"> <Order>3</Order> + <CommandLine>CMD /C echo GG&gt;C:\Windows\LogOobeSystem.txt</CommandLine> + </SynchronousCommand> + <SynchronousCommand wcm:action="add"> + <Order>4</Order> <CommandLine>powershell -ExecutionPolicy Bypass -File c:\windows\FirstStartup.ps1</CommandLine> </SynchronousCommand> </FirstLogonCommands> @@ -343,10 +368,218 @@ function New-Unattend { $specPass = @' <settings pass="specialize"> <component name="Microsoft-Windows-SQMApi" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <CEIPEnabled>0</CEIPEnabled> + <CEIPEnabled>0</CEIPEnabled> </component> <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - <ConfigureChatAutoInstall>false</ConfigureChatAutoInstall> + <ConfigureChatAutoInstall>false</ConfigureChatAutoInstall> + </component> + <component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"> + <RunSynchronous> + <RunSynchronousCommand wcm:action="add"> + <Order>1</Order> + <Path>reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\OOBE" /v BypassNRO /t REG_DWORD /d 1 /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>2</Order> + <Path>reg.exe load "HKU\DefaultUser" "C:\Users\Default\NTUSER.DAT"</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>3</Order> + <Path>reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\Runonce" /v "UninstallCopilot" /t REG_SZ /d "powershell.exe -NoProfile -Command \"Get-AppxPackage -Name 'Microsoft.Windows.Ai.Copilot.Provider' | Remove-AppxPackage;\"" /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>4</Order> + <Path>reg.exe add "HKU\DefaultUser\Software\Policies\Microsoft\Windows\WindowsCopilot" /v TurnOffWindowsCopilot /t REG_DWORD /d 1 /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>5</Order> + <Path>reg.exe unload "HKU\DefaultUser"</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>6</Order> + <Path>reg.exe delete "HKLM\SOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\DevHomeUpdate" /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>7</Order> + <Path>reg.exe load "HKU\DefaultUser" "C:\Users\Default\NTUSER.DAT"</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>8</Order> + <Path>reg.exe add "HKU\DefaultUser\Software\Microsoft\Notepad" /v ShowStoreBanner /t REG_DWORD /d 0 /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>9</Order> + <Path>reg.exe unload "HKU\DefaultUser"</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>10</Order> + <Path>cmd.exe /c "del "C:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk""</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>11</Order> + <Path>cmd.exe /c "del "C:\Windows\System32\OneDriveSetup.exe""</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>12</Order> + <Path>cmd.exe /c "del "C:\Windows\SysWOW64\OneDriveSetup.exe""</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>13</Order> + <Path>reg.exe load "HKU\DefaultUser" "C:\Users\Default\NTUSER.DAT"</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>14</Order> + <Path>reg.exe delete "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\Run" /v OneDriveSetup /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>15</Order> + <Path>reg.exe unload "HKU\DefaultUser"</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>16</Order> + <Path>reg.exe delete "HKLM\SOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\OutlookUpdate" /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>17</Order> + <Path>reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Communications" /v ConfigureChatAutoInstall /t REG_DWORD /d 0 /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>18</Order> + <Path>powershell.exe -NoProfile -Command "$xml = [xml]::new(); $xml.Load('C:\Windows\Panther\unattend.xml'); $sb = [scriptblock]::Create( $xml.unattend.Extensions.ExtractScript ); Invoke-Command -ScriptBlock $sb -ArgumentList $xml;"</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>19</Order> + <Path>powershell.exe -NoProfile -Command "Get-Content -LiteralPath 'C:\Windows\Temp\remove-packages.ps1' -Raw | Invoke-Expression;"</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>20</Order> + <Path>powershell.exe -NoProfile -Command "Get-Content -LiteralPath 'C:\Windows\Temp\remove-caps.ps1' -Raw | Invoke-Expression;"</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>21</Order> + <Path>reg.exe add "HKLM\SOFTWARE\Microsoft\PolicyManager\current\device\Start" /v ConfigureStartPins /t REG_SZ /d "{ \"pinnedList\": [] }" /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>22</Order> + <Path>reg.exe add "HKLM\SOFTWARE\Microsoft\PolicyManager\current\device\Start" /v ConfigureStartPins_ProviderSet /t REG_DWORD /d 1 /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>23</Order> + <Path>reg.exe add "HKLM\SOFTWARE\Microsoft\PolicyManager\current\device\Start" /v ConfigureStartPins_WinningProvider /t REG_SZ /d B5292708-1619-419B-9923-E5D9F3925E71 /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>24</Order> + <Path>reg.exe add "HKLM\SOFTWARE\Microsoft\PolicyManager\providers\B5292708-1619-419B-9923-E5D9F3925E71\default\Device\Start" /v ConfigureStartPins /t REG_SZ /d "{ \"pinnedList\": [] }" /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>25</Order> + <Path>reg.exe add "HKLM\SOFTWARE\Microsoft\PolicyManager\providers\B5292708-1619-419B-9923-E5D9F3925E71\default\Device\Start" /v ConfigureStartPins_LastWrite /t REG_DWORD /d 1 /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>26</Order> + <Path>net.exe accounts /maxpwage:UNLIMITED</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>27</Order> + <Path>reg.exe add "HKLM\SYSTEM\CurrentControlSet\Control\FileSystem" /v LongPathsEnabled /t REG_DWORD /d 1 /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>28</Order> + <Path>reg.exe add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Power" /v HiberbootEnabled /t REG_DWORD /d 0 /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>29</Order> + <Path>reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Dsh" /v AllowNewsAndInterests /t REG_DWORD /d 0 /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>30</Order> + <Path>reg.exe load "HKU\DefaultUser" "C:\Users\Default\NTUSER.DAT"</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>31</Order> + <Path>reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "ContentDeliveryAllowed" /t REG_DWORD /d 0 /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>32</Order> + <Path>reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "FeatureManagementEnabled" /t REG_DWORD /d 0 /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>33</Order> + <Path>reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "OEMPreInstalledAppsEnabled" /t REG_DWORD /d 0 /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>34</Order> + <Path>reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "PreInstalledAppsEnabled" /t REG_DWORD /d 0 /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>35</Order> + <Path>reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "PreInstalledAppsEverEnabled" /t REG_DWORD /d 0 /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>36</Order> + <Path>reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SilentInstalledAppsEnabled" /t REG_DWORD /d 0 /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>37</Order> + <Path>reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SoftLandingEnabled" /t REG_DWORD /d 0 /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>38</Order> + <Path>reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContentEnabled" /t REG_DWORD /d 0 /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>39</Order> + <Path>reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContent-310093Enabled" /t REG_DWORD /d 0 /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>40</Order> + <Path>reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContent-338387Enabled" /t REG_DWORD /d 0 /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>41</Order> + <Path>reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContent-338388Enabled" /t REG_DWORD /d 0 /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>42</Order> + <Path>reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContent-338389Enabled" /t REG_DWORD /d 0 /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>43</Order> + <Path>reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContent-338393Enabled" /t REG_DWORD /d 0 /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>44</Order> + <Path>reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SubscribedContent-353698Enabled" /t REG_DWORD /d 0 /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>45</Order> + <Path>reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v "SystemPaneSuggestionsEnabled" /t REG_DWORD /d 0 /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>46</Order> + <Path>reg.exe unload "HKU\DefaultUser"</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>47</Order> + <Path>reg.exe add "HKLM\Software\Policies\Microsoft\Windows\CloudContent" /v "DisableWindowsConsumerFeatures" /t REG_DWORD /d 0 /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>48</Order> + <Path>reg.exe add "HKLM\SYSTEM\CurrentControlSet\Control\BitLocker" /v "PreventDeviceEncryption" /t REG_DWORD /d 1 /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>49</Order> + <Path>reg.exe load "HKU\DefaultUser" "C:\Users\Default\NTUSER.DAT"</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>50</Order> + <Path>reg.exe add "HKU\DefaultUser\Software\Microsoft\Windows\CurrentVersion\Runonce" /v "ClassicContextMenu" /t REG_SZ /d "reg.exe add \"HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32\" /ve /f" /f</Path> + </RunSynchronousCommand> + <RunSynchronousCommand wcm:action="add"> + <Order>51</Order> + <Path>reg.exe unload "HKU\DefaultUser"</Path> + </RunSynchronousCommand> + </RunSynchronous> </component> </settings> '@ diff --git a/functions/public/Invoke-WPFMicrowin.ps1 b/functions/public/Invoke-WPFMicrowin.ps1 index b0f34ad2..5f547608 100644 --- a/functions/public/Invoke-WPFMicrowin.ps1 +++ b/functions/public/Invoke-WPFMicrowin.ps1 @@ -347,7 +347,7 @@ public class PowerManagement { # Copied here After Installation (Online) # reg delete "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Orchestrator\UScheduler\$_" /f | Out-Null - + # When in Offline Image reg delete "HKLM\zSOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\$_" /f | Out-Null } From bdfc4c076c4d2c1054147b122b1330830d4dec35 Mon Sep 17 00:00:00 2001 From: Chris Titus Tech <dfm.titus@gmail.com> Date: Tue, 13 Aug 2024 11:16:31 -0500 Subject: [PATCH 08/23] Cleanup first run --- .../private/Invoke-WinUtilMicroWin-Helper.ps1 | 88 ------------------- 1 file changed, 88 deletions(-) diff --git a/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 b/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 index 15b42582..1539f5e3 100644 --- a/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 +++ b/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 @@ -699,94 +699,8 @@ function New-FirstRun { } } - function Stop-UnnecessaryServices { - $servicesToExclude = @( - "AudioSrv", - "AudioEndpointBuilder", - "BFE", - "BITS", - "BrokerInfrastructure", - "CDPSvc", - "CDPUserSvc_dc2a4", - "CoreMessagingRegistrar", - "CryptSvc", - "DPS", - "DcomLaunch", - "Dhcp", - "DispBrokerDesktopSvc", - "Dnscache", - "DoSvc", - "DusmSvc", - "EventLog", - "EventSystem", - "FontCache", - "LSM", - "LanmanServer", - "LanmanWorkstation", - "MapsBroker", - "MpsSvc", - "OneSyncSvc_dc2a4", - "Power", - "ProfSvc", - "RpcEptMapper", - "RpcSs", - "SCardSvr", - "SENS", - "SamSs", - "Schedule", - "SgrmBroker", - "ShellHWDetection", - "Spooler", - "SysMain", - "SystemEventsBroker", - "TextInputManagementService", - "Themes", - "TrkWks", - "UserManager", - "VGAuthService", - "VMTools", - "WSearch", - "Wcmsvc", - "WinDefend", - "Winmgmt", - "WlanSvc", - "WpnService", - "WpnUserService_dc2a4", - "cbdhsvc_dc2a4", - "edgeupdate", - "gpsvc", - "iphlpsvc", - "mpssvc", - "nsi", - "sppsvc", - "tiledatamodelsvc", - "vm3dservice", - "webthreatdefusersvc_dc2a4", - "wscsvc" -) - - $runningServices = Get-Service | Where-Object { $servicesToExclude -notcontains $_.Name } - foreach($service in $runningServices) { - Stop-Service -Name $service.Name -PassThru - Set-Service $service.Name -StartupType Manual - "Stopping service $($service.Name)" | Out-File -FilePath c:\windows\LogFirstRun.txt -Append -NoClobber - } - } - "FirstStartup has worked" | Out-File -FilePath c:\windows\LogFirstRun.txt -Append -NoClobber - $Theme = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize" - Set-ItemProperty -Path $Theme -Name AppsUseLightTheme -Value 1 - Set-ItemProperty -Path $Theme -Name SystemUsesLightTheme -Value 1 - - # figure this out later how to set updates to security only - #Import-Module -Name PSWindowsUpdate; - #Stop-Service -Name wuauserv - #Set-WUSettings -MicrosoftUpdateEnabled -AutoUpdateOption 'Never' - #Start-Service -Name wuauserv - - Stop-UnnecessaryServices - $taskbarPath = "$env:AppData\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar" # Delete all files on the Taskbar Get-ChildItem -Path $taskbarPath -File | Remove-Item -Force @@ -794,8 +708,6 @@ function New-FirstRun { Remove-RegistryValue -RegistryPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband" -ValueName "FavoritesChanges" Remove-RegistryValue -RegistryPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband" -ValueName "Favorites" - # Stop-Process -Name explorer -Force - $process = Get-Process -Name "explorer" Stop-Process -InputObject $process # Wait for the process to exit From 0e85f20680ec7e336086b7f992791e3b12737289 Mon Sep 17 00:00:00 2001 From: Chris Titus Tech <dfm.titus@gmail.com> Date: Tue, 13 Aug 2024 11:47:19 -0500 Subject: [PATCH 09/23] Fix Hangup with Microwin --- functions/private/Invoke-WinUtilMicroWin-Helper.ps1 | 6 ------ 1 file changed, 6 deletions(-) diff --git a/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 b/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 index 1539f5e3..329a686a 100644 --- a/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 +++ b/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 @@ -708,12 +708,6 @@ function New-FirstRun { Remove-RegistryValue -RegistryPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband" -ValueName "FavoritesChanges" Remove-RegistryValue -RegistryPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband" -ValueName "Favorites" - $process = Get-Process -Name "explorer" - Stop-Process -InputObject $process - # Wait for the process to exit - Wait-Process -InputObject $process - Start-Sleep -Seconds 3 - # Delete Edge Icon from the desktop $edgeShortcutFiles = Get-ChildItem -Path $desktopPath -Filter "*Edge*.lnk" # Check if Edge shortcuts exist on the desktop From 35dfd847ab081b4092cdc1cf7d36745eb34d5299 Mon Sep 17 00:00:00 2001 From: Chris Titus Tech <dfm.titus@gmail.com> Date: Tue, 13 Aug 2024 12:04:09 -0500 Subject: [PATCH 10/23] MicroWin Cleanup --- .../private/Invoke-WinUtilMicroWin-Helper.ps1 | 100 ++++-------------- functions/public/Invoke-WPFMicrowin.ps1 | 54 +--------- xaml/inputXML.xaml | 13 +-- 3 files changed, 25 insertions(+), 142 deletions(-) diff --git a/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 b/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 index 329a686a..79c1f00b 100644 --- a/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 +++ b/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 @@ -25,25 +25,22 @@ function Test-CompatibleImage() { } } -function Remove-Features([switch]$dumpFeatures = $false, [switch]$keepDefender = $false) { +function Remove-Features() { <# .SYNOPSIS Removes certain features from ISO image .PARAMETER Name - dumpFeatures - Dumps all features found in the ISO into a file called allfeaturesdump.txt. This file can be examined and used to decide what to remove. - keepDefender - Should Defender be removed from the ISO? + No Params .EXAMPLE - Remove-Features -keepDefender:$false + Remove-Features #> try { $featlist = (Get-WindowsOptionalFeature -Path $scratchDir).FeatureName - if ($dumpFeatures) { - $featlist > allfeaturesdump.txt - } $featlist = $featlist | Where-Object { + $_ -NotLike "*Defender*" -AND $_ -NotLike "*Printing*" -AND $_ -NotLike "*TelnetClient*" -AND $_ -NotLike "*PowerShell*" -AND @@ -52,8 +49,6 @@ function Remove-Features([switch]$dumpFeatures = $false, [switch]$keepDefender = $_ -NotLike "*NFS*" } - if ($keepDefender) { $featlist = $featlist | Where-Object { $_ -NotLike "*Defender*" }} - foreach($feature in $featlist) { $status = "Removing feature $feature" Write-Progress -Activity "Removing features" -Status $status -PercentComplete ($counter++/$featlist.Count*100) @@ -126,16 +121,16 @@ function Remove-Packages { } } -function Remove-ProvisionedPackages([switch]$keepSecurity = $false) { +function Remove-ProvisionedPackages() { <# .SYNOPSIS Removes AppX packages from a Windows image during MicroWin processing .PARAMETER Name - keepSecurity - Boolean that determines whether to keep "Microsoft.SecHealthUI" (Windows Security) in the Windows image + No Params .EXAMPLE - Remove-ProvisionedPackages -keepSecurity:$false + Remove-ProvisionedPackages #> $appxProvisionedPackages = Get-AppxProvisionedPackage -Path "$($scratchDir)" | Where-Object { $_.PackageName -NotLike "*AppInstaller*" -AND @@ -151,22 +146,19 @@ function Remove-ProvisionedPackages([switch]$keepSecurity = $false) { } if ($?) { - if ($keepSecurity) { $appxProvisionedPackages = $appxProvisionedPackages | Where-Object { $_.PackageName -NotLike "*SecHealthUI*" }} - $counter = 0 - foreach ($appx in $appxProvisionedPackages) { - $status = "Removing Provisioned $($appx.PackageName)" - Write-Progress -Activity "Removing Provisioned Apps" -Status $status -PercentComplete ($counter++/$appxProvisionedPackages.Count*100) - try { - Remove-AppxProvisionedPackage -Path "$scratchDir" -PackageName $appx.PackageName -ErrorAction SilentlyContinue - } catch { - Write-Host "Application $($appx.PackageName) could not be removed" - continue - } + $appxProvisionedPackages = $appxProvisionedPackages | Where-Object { $_.PackageName -NotLike "*SecHealthUI*" } + $counter = 0 + foreach ($appx in $appxProvisionedPackages) { + $status = "Removing Provisioned $($appx.PackageName)" + Write-Progress -Activity "Removing Provisioned Apps" -Status $status -PercentComplete ($counter++/$appxProvisionedPackages.Count*100) + try { + Remove-AppxProvisionedPackage -Path "$scratchDir" -PackageName $appx.PackageName -ErrorAction SilentlyContinue + } catch { + Write-Host "Application $($appx.PackageName) could not be removed" + continue } - Write-Progress -Activity "Removing Provisioned Apps" -Status "Ready" -Completed - } else { - Write-Host "Could not get Provisioned App information. Skipping process..." } + Write-Progress -Activity "Removing Provisioned Apps" -Status "Ready" -Completed } function Copy-ToUSB([string]$fileToCopy) { @@ -200,22 +192,6 @@ function Remove-FileOrDirectory([string]$pathToDelete, [string]$mask = "", [swit $yesNo = Get-LocalizedYesNo Write-Host "[INFO] In Your local takeown expects '$($yesNo[0])' as a Yes answer." - # Specify the path to the directory - # $directoryPath = "$($scratchDir)\Windows\System32\LogFiles\WMI\RtBackup" - # takeown /a /r /d $yesNo[0] /f "$($directoryPath)" > $null - # icacls "$($directoryPath)" /q /c /t /reset > $null - # icacls $directoryPath /setowner "*S-1-5-32-544" - # icacls $directoryPath /grant "*S-1-5-32-544:(OI)(CI)F" /t /c /q - # Remove-Item -Path $directoryPath -Recurse -Force - - # # Grant full control to BUILTIN\Administrators using icacls - # $directoryPath = "$($scratchDir)\Windows\System32\WebThreatDefSvc" - # takeown /a /r /d $yesNo[0] /f "$($directoryPath)" > $null - # icacls "$($directoryPath)" /q /c /t /reset > $null - # icacls $directoryPath /setowner "*S-1-5-32-544" - # icacls $directoryPath /grant "*S-1-5-32-544:(OI)(CI)F" /t /c /q - # Remove-Item -Path $directoryPath -Recurse -Force - $itemsToDelete = [System.Collections.ArrayList]::new() if ($mask -eq "") { @@ -254,46 +230,6 @@ function Remove-FileOrDirectory([string]$pathToDelete, [string]$mask = "", [swit function New-Unattend { - # later if we wont to remove even more bloat EU requires MS to remove everything from English(world) - # Below is an example how to do it we probably should create a drop down with common locals - # <settings pass="specialize"> - # <!-- Specify English (World) locale --> - # <component name="Microsoft-Windows-International-Core" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - # <SetupUILanguage> - # <UILanguage>en-US</UILanguage> - # </SetupUILanguage> - # <InputLocale>en-US</InputLocale> - # <SystemLocale>en-US</SystemLocale> - # <UILanguage>en-US</UILanguage> - # <UserLocale>en-US</UserLocale> - # </component> - # </settings> - - # <settings pass="oobeSystem"> - # <!-- Specify English (World) locale --> - # <component name="Microsoft-Windows-International-Core" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> - # <InputLocale>en-US</InputLocale> - # <SystemLocale>en-US</SystemLocale> - # <UILanguage>en-US</UILanguage> - # <UserLocale>en-US</UserLocale> - # </component> - # </settings> - # using here string to embedd unattend - # <RunSynchronousCommand wcm:action="add"> - # <Order>1</Order> - # <Path>net user administrator /active:yes</Path> - # </RunSynchronousCommand> - - # this section doesn't work in win10/???? -# <settings pass="specialize"> -# <component name="Microsoft-Windows-SQMApi" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> -# <CEIPEnabled>0</CEIPEnabled> -# </component> -# <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> -# <ConfigureChatAutoInstall>false</ConfigureChatAutoInstall> -# </component> -# </settings> - $unattend = @' <?xml version="1.0" encoding="utf-8"?> <unattend xmlns="urn:schemas-microsoft-com:unattend" diff --git a/functions/public/Invoke-WPFMicrowin.ps1 b/functions/public/Invoke-WPFMicrowin.ps1 index 5f547608..15a9e001 100644 --- a/functions/public/Invoke-WPFMicrowin.ps1 +++ b/functions/public/Invoke-WPFMicrowin.ps1 @@ -151,37 +151,15 @@ public class PowerManagement { } Write-Host "Remove Features from the image" - Remove-Features -keepDefender:$keepDefender + Remove-Features Write-Host "Removing features complete!" + Write-Host "Removing OS packages" + Remove-Packages + Write-Host "Removing Appx Bloat" + Remove-ProvisionedPackages - if (!$keepPackages) { - Write-Host "Removing OS packages" - Remove-Packages - } - if (!$keepProvisionedPackages) { - Write-Host "Removing Appx Bloat" - Remove-ProvisionedPackages -keepSecurity:$keepDefender - } - - # special code, for some reason when you try to delete some inbox apps - # we have to get and delete log files directory. Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\System32\LogFiles\WMI\RtBackup" -Directory Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\System32\WebThreatDefSvc" -Directory - - # Defender is hidden in 2 places we removed a feature above now need to remove it from the disk - if (!$keepDefender) { - Write-Host "Removing Defender" - Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Program Files\Windows Defender" -Directory - Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Program Files (x86)\Windows Defender" - } - # if (!$keepEdge) { - # # this is destructive and might result in touching SystemApps is not recommended unless you going complete rogue on trimming edge and telemetry - # Write-Host "Removing Edge" - # Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Program Files (x86)\Microsoft" -mask "*edge*" -Directory - # Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Program Files\Microsoft" -mask "*edge*" -Directory - # Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\SystemApps" -mask "*edge*" -Directory - # } - Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\DiagTrack" -Directory Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\InboxApps" -Directory Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\System32\SecurityHealthSystray.exe" @@ -226,28 +204,6 @@ public class PowerManagement { New-Item -ItemType Directory -Force -Path "$desktopDir" dism /English /image:$($scratchDir) /set-profilepath:"$($scratchDir)\Windows\Users\Default" - # $command = "powershell.exe -NoProfile -ExecutionPolicy Bypass -Command 'irm https://christitus.com/win | iex'" - # $shortcutPath = "$desktopDir\WinUtil.lnk" - # $shell = New-Object -ComObject WScript.Shell - # $shortcut = $shell.CreateShortcut($shortcutPath) - - # if (Test-Path -Path "$env:TEMP\cttlogo.png") - # { - # $pngPath = "$env:TEMP\cttlogo.png" - # $icoPath = "$env:TEMP\cttlogo.ico" - # ConvertTo-Icon -bitmapPath $pngPath -iconPath $icoPath - # Write-Host "ICO file created at: $icoPath" - # Copy-Item "$env:TEMP\cttlogo.png" "$($scratchDir)\Windows\cttlogo.png" -force - # Copy-Item "$env:TEMP\cttlogo.ico" "$($scratchDir)\Windows\cttlogo.ico" -force - # $shortcut.IconLocation = "c:\Windows\cttlogo.ico" - # } - - # $shortcut.TargetPath = "powershell.exe" - # $shortcut.Arguments = "-NoProfile -ExecutionPolicy Bypass -Command `"$command`"" - # $shortcut.Save() - # Write-Host "Shortcut to winutil created at: $shortcutPath" - # *************************** Automation black *************************** - Write-Host "Copy checkinstall.cmd into the ISO" New-CheckInstall Copy-Item "$env:temp\checkinstall.cmd" "$($scratchDir)\Windows\checkinstall.cmd" -force diff --git a/xaml/inputXML.xaml b/xaml/inputXML.xaml index 2ba9d635..7441cc1f 100644 --- a/xaml/inputXML.xaml +++ b/xaml/inputXML.xaml @@ -904,11 +904,6 @@ <StackPanel Name="MicrowinOptionsPanel" HorizontalAlignment="Left" SnapsToDevicePixels="True" Margin="1" Visibility="Hidden"> <TextBlock Margin="6" Padding="1" TextWrapping="Wrap">Choose Windows SKU</TextBlock> <ComboBox x:Name = "MicrowinWindowsFlavors" Margin="1" /> - <TextBlock Margin="6" Padding="1" TextWrapping="Wrap">Choose Windows features you want to remove from the ISO</TextBlock> - <CheckBox Name="WPFMicrowinKeepProvisionedPackages" Content="Keep Provisioned Packages" Margin="-10,5,0,0" ToolTip="Do not remove Microsoft Provisioned packages from the ISO."/> - <CheckBox Name="WPFMicrowinKeepAppxPackages" Content="Keep Appx Packages" Margin="-10,5,0,0" ToolTip="Do not remove Microsoft Appx packages from the ISO."/> - <CheckBox Name="WPFMicrowinKeepDefender" Content="Keep Defender" Margin="-10,5,0,0" IsChecked="True" ToolTip="Do not remove Microsoft Antivirus from the ISO."/> - <CheckBox Name="WPFMicrowinKeepEdge" Content="Keep Edge" Margin="-10,5,0,0" IsChecked="True" ToolTip="Do not remove Microsoft Edge from the ISO."/> <Rectangle Fill="{MainForegroundColor}" Height="2" HorizontalAlignment="Stretch" Margin="0,10,0,10"/> <CheckBox Name="MicrowinInjectDrivers" Content="Inject drivers (I KNOW WHAT I'M DOING)" Margin="-10,5,0,0" IsChecked="False" ToolTip="Path to unpacked drivers all sys and inf files for devices that need drivers"/> <TextBox Name="MicrowinDriverLocation" Background="Transparent" BorderThickness="1" BorderBrush="{MainForegroundColor}" @@ -970,11 +965,8 @@ Foreground="{ComboBoxForegroundColor}"> <Bold>MicroWin features:</Bold><LineBreak/> - Remove Telemetry and Tracking <LineBreak/> - - Add ability to use local accounts <LineBreak/> - - Remove Wifi requirement to finish install <LineBreak/> - - Ability to remove Edge <LineBreak/> - - Ability to remove Defender <LineBreak/> - - Remove Teams <LineBreak/> + - Fast Install using "User" local account <LineBreak/> + - No internet requirement for install <LineBreak/> - Apps debloat <LineBreak/> <LineBreak/> <LineBreak/> @@ -988,7 +980,6 @@ - Click on the "Select Windows ISO" button and wait for WinUtil to process the image <LineBreak/> It will be processed and unpacked which may take some time <LineBreak/> - Once complete, choose which Windows flavor you want to base your image on <LineBreak/> - - Choose which features you want to keep <LineBreak/> - Click the "Start Process" button <LineBreak/> The process of creating the Windows image may take some time, please check the console and wait for it to say "Done" <LineBreak/> - Once complete, the target ISO file will be in the directory you have specified <LineBreak/> From bf518522f8b55cddb9ff3a90914b12ff660ccce8 Mon Sep 17 00:00:00 2001 From: Chris Titus Tech <dfm.titus@gmail.com> Date: Tue, 13 Aug 2024 12:09:47 -0500 Subject: [PATCH 11/23] fix error --- functions/private/Invoke-WinUtilMicroWin-Helper.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 b/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 index 79c1f00b..15be02d8 100644 --- a/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 +++ b/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 @@ -145,7 +145,6 @@ function Remove-ProvisionedPackages() { $_.PackageName -NotLike "*Foundation*" } - if ($?) { $appxProvisionedPackages = $appxProvisionedPackages | Where-Object { $_.PackageName -NotLike "*SecHealthUI*" } $counter = 0 foreach ($appx in $appxProvisionedPackages) { From a046bcd6a2760d02205cb705cf5257776835bbd9 Mon Sep 17 00:00:00 2001 From: Chris Titus Tech <dfm.titus@gmail.com> Date: Tue, 13 Aug 2024 12:33:44 -0500 Subject: [PATCH 12/23] Fix provisioned packages --- .../private/Invoke-WinUtilMicroWin-Helper.ps1 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 b/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 index 15be02d8..bdd843f8 100644 --- a/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 +++ b/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 @@ -142,10 +142,20 @@ function Remove-ProvisionedPackages() { $_.PackageName -NotLike "*Notepad*" -and $_.PackageName -NotLike "*Printing*" -and $_.PackageName -NotLike "*Wifi*" -and - $_.PackageName -NotLike "*Foundation*" + $_.PackageName -NotLike "*Foundation*" -and + $_.PackageName -NotLike "*YourPhone*" -and + $_.PackageName -NotLike "*Xbox*" -and + $_.PackageName -NotLike "*WindowsTerminal*" -and + $_.PackageName -NotLike "*Calculator*" -and + $_.PackageName -NotLike "*Photos*" -and + $_.PackageName -NotLike "*VCLibs*" -and + $_.PackageName -NotLike "*Paint*" -and + $_.PackageName -NotLike "*Gaming*" -and + $_.PackageName -NotLike "*Extension*" -and + $_.PackageName -NotLike "*SecHealthUI*" + } - $appxProvisionedPackages = $appxProvisionedPackages | Where-Object { $_.PackageName -NotLike "*SecHealthUI*" } $counter = 0 foreach ($appx in $appxProvisionedPackages) { $status = "Removing Provisioned $($appx.PackageName)" From ed1cdf0233c4473846fdf72983ca8c939e0b3b0f Mon Sep 17 00:00:00 2001 From: Chris Titus Tech <dfm.titus@gmail.com> Date: Tue, 13 Aug 2024 13:02:09 -0500 Subject: [PATCH 13/23] update microwin again --- functions/public/Invoke-WPFMicrowin.ps1 | 57 ------------------------- 1 file changed, 57 deletions(-) diff --git a/functions/public/Invoke-WPFMicrowin.ps1 b/functions/public/Invoke-WPFMicrowin.ps1 index 15a9e001..9bb89194 100644 --- a/functions/public/Invoke-WPFMicrowin.ps1 +++ b/functions/public/Invoke-WPFMicrowin.ps1 @@ -159,10 +159,8 @@ public class PowerManagement { Remove-ProvisionedPackages Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\System32\LogFiles\WMI\RtBackup" -Directory - Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\System32\WebThreatDefSvc" -Directory Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\DiagTrack" -Directory Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\InboxApps" -Directory - Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\System32\SecurityHealthSystray.exe" Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\System32\LocationNotificationWindows.exe" Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Program Files (x86)\Windows Photo Viewer" -Directory Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Program Files\Windows Photo Viewer" -Directory @@ -175,9 +173,7 @@ public class PowerManagement { Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\GameBarPresenceWriter" Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\System32\OneDriveSetup.exe" Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\System32\OneDrive.ico" - Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\SystemApps" -mask "*Windows.Search*" -Directory Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\SystemApps" -mask "*narratorquickstart*" -Directory - Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\SystemApps" -mask "*Xbox*" -Directory Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\SystemApps" -mask "*ParentalControls*" -Directory Write-Host "Removal complete!" @@ -239,59 +235,6 @@ public class PowerManagement { reg add "HKLM\zSYSTEM\Setup\LabConfig" /v "BypassTPMCheck" /t REG_DWORD /d 1 /f reg add "HKLM\zSYSTEM\Setup\MoSetup" /v "AllowUpgradesWithUnsupportedTPMOrCPU" /t REG_DWORD /d 1 /f - if (!$keepEdge) { - # Undo changes made by -> Dism Add-Edge Edge.wim (Trust Me: this is the non-destructive way to unintegrate Edge) - - Write-Host "Removing Edge" - - # Microsoft Edge - reg delete "HKLM\zSOFTWARE\Microsoft\Active Setup\Installed Components\{9459C573-B17A-45AE-9F64-1857B5D58CEE}" /f | Out-Null - - reg delete "HKLM\zSOFTWARE\Wow6432Node\Microsoft\EdgeUpdate\Clients\{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" /f | Out-Null - reg delete "HKLM\zSOFTWARE\Wow6432Node\Microsoft\EdgeUpdate\ClientState\{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}" /f | Out-Null - - reg delete "HKLM\zSOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge" /f | Out-Null - - if (Test-Path "$scratchDir\Program Files (x86)\Microsoft\Edge" -Type Container) { - Remove-Item "$scratchDir\Program Files (x86)\Microsoft\Edge" -Recurse -Force | Out-Null - } - - # Extra - reg delete "HKLM\zSOFTWARE\Microsoft\MicrosoftEdge" /f | Out-Null - - # Microsoft EdgeWebView - reg delete "HKLM\zSOFTWARE\Wow6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" /f | Out-Null - reg delete "HKLM\zSOFTWARE\Wow6432Node\Microsoft\EdgeUpdate\ClientState\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" /f | Out-Null - - reg delete "HKLM\zSOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft EdgeWebView" /f | Out-Null - - if (Test-Path "$scratchDir\Program Files (x86)\Microsoft\EdgeWebView" -Type Container) { - Remove-Item "$scratchDir\Program Files (x86)\Microsoft\EdgeWebView" -Recurse -Force | Out-Null - } - - # Edge Core - if (Test-Path "$scratchDir\Program Files (x86)\Microsoft\EdgeCore" -Type Container) { - Remove-Item "$scratchDir\Program Files (x86)\Microsoft\EdgeCore" -Recurse -Force | Out-Null - } - - # Microsoft Edge Update - reg delete "HKLM\zSOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\MicrosoftEdgeUpdate.exe" /f | Out-Null - - reg delete "HKLM\zSOFTWARE\Wow6432Node\Microsoft\EdgeUpdate" /f | Out-Null - reg delete "HKLM\zSOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge Update" /f | Out-Null - - # Microsoft Edge Update :: Services - reg delete "HKLM\zSYSTEM\ControlSet001\Services\edgeupdate" /f | Out-Null - reg delete "HKLM\zSYSTEM\ControlSet001\Services\edgeupdatem" /f | Out-Null - - if (Test-Path "$scratchDir\Program Files (x86)\Microsoft\EdgeUpdate" -Type Container) { - Remove-Item "$scratchDir\Program Files (x86)\Microsoft\EdgeUpdate" -Recurse -Force | Out-Null - } - - # Prevent EdgeChromium from Installing in the future - reg add "HKLM\zSOFTWARE\Microsoft\EdgeUpdate" /v "DoNotUpdateToEdgeWithChromium" /t REG_DWORD /d "1" /f | Out-Null - } - # Prevent Windows Update Installing so called Expedited Apps @( 'EdgeUpdate', From 6c3539edbec6f64681089144a51e3d11d9957ed7 Mon Sep 17 00:00:00 2001 From: MyDrift <personal@mdiana.ch> Date: Tue, 13 Aug 2024 20:49:08 +0200 Subject: [PATCH 14/23] Edge removal improvements (#2540) * readd changes - change uninstall function call - remove winget install code - add edge install function call - remove reg keys causing cursed open with contect menu - remove edge policy keys - remove edge keys - remove edgeupdate keys - add install edg logics * add silent installation * error handling * add ... --- config/tweaks.json | 9 +--- .../private/Uninstall-WinUtilEdgeBrowser.ps1 | 43 +++++++++++++++++-- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/config/tweaks.json b/config/tweaks.json index 8702322f..07c17d85 100644 --- a/config/tweaks.json +++ b/config/tweaks.json @@ -2561,15 +2561,10 @@ "panel": "1", "Order": "a029_", "InvokeScript": [ - " - Uninstall-WinUtilEdgeBrowser - " + "Uninstall-WinUtilEdgeBrowser -action \"Uninstall\"" ], "UndoScript": [ - " - Write-Host \"Install Microsoft Edge\" - Start-Process -FilePath winget -ArgumentList \"install --force -e --accept-source-agreements --accept-package-agreements --silent Microsoft.Edge \" -NoNewWindow -Wait - " + "Uninstall-WinUtilEdgeBrowser -action \"Install\"" ], "link": "https://christitustech.github.io/winutil/dev/tweaks/z--Advanced-Tweaks---CAUTION/RemoveEdge" }, diff --git a/functions/private/Uninstall-WinUtilEdgeBrowser.ps1 b/functions/private/Uninstall-WinUtilEdgeBrowser.ps1 index 4d004f39..f090e95f 100644 --- a/functions/private/Uninstall-WinUtilEdgeBrowser.ps1 +++ b/functions/private/Uninstall-WinUtilEdgeBrowser.ps1 @@ -6,6 +6,12 @@ Function Uninstall-WinUtilEdgeBrowser { This will switch up the region to one of the EEA countries temporarily and uninstall the Edge Browser (Chromium). #> + param ( + [Parameter(Mandatory = $true)] + [ValidateSet("install", "uninstall")] + [string]$action + ) + function Uninstall-EdgeClient { param ( [Parameter(Mandatory = $true)] @@ -65,6 +71,16 @@ Function Uninstall-WinUtilEdgeBrowser { [microsoft.win32.registry]::SetValue("HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdateDev", "AllowUninstall", 1, [Microsoft.Win32.RegistryValueKind]::DWord) | Out-Null Uninstall-EdgeClient -Key '{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}' + + Remove-Item -Path "Computer\\HKEY_CLASSES_ROOT\\MSEdgePDF" -ErrorAction SilentlyContinue | Out-Null + Remove-Item -Path "Computer\\HKEY_CLASSES_ROOT\\MSEdgeHTM" -ErrorAction SilentlyContinue | Out-Null + Remove-Item -Path "Computer\\HKEY_CLASSES_ROOT\\MSEdgeMHT" -ErrorAction SilentlyContinue | Out-Null + + # Remove Edge Polocy reg keys + Remove-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Edge" -Recurse -ErrorAction SilentlyContinue | Out-Null + + # Remove Edge reg keys + Remove-Item -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Edge" -Recurse -ErrorAction SilentlyContinue | Out-Null } function Uninstall-WebView { @@ -93,9 +109,30 @@ Function Uninstall-WinUtilEdgeBrowser { } Start-Process cmd.exe "/c $uninstallCmdLine" -WindowStyle Hidden -Wait + + # Remove EdgeUpdate reg keys + Remove-Item -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate" -Recurse -ErrorAction SilentlyContinue | Out-Null } - Uninstall-Edge - # Uninstall-WebView - WebView is needed for Visual Studio and some MS Store Games like Forza - Uninstall-EdgeUpdate + function Install-Edge { + $tempEdgePath = "$env:TEMP\MicrosoftEdgeSetup.exe" + + try { + write-host "Installing Edge ..." + Invoke-WebRequest -Uri "https://go.microsoft.com/fwlink/?linkid=2109047&Channel=Stable&language=en&consent=1" -OutFile $tempEdgePath + Start-Process -FilePath $tempEdgePath -ArgumentList "/silent /install" -Wait + Remove-item $tempEdgePath + write-host "Edge Installed Successfully" + } catch { + write-host "Failed to install Edge" + } + } + + if ($action -eq "Install") { + Install-Edge + } elseif ($action -eq "Uninstall") { + Uninstall-Edge + Uninstall-EdgeUpdate + # Uninstall-WebView - WebView is needed for Visual Studio and some MS Store Games like Forza + } } From 8fd08f7ac540e27b2a4aa8a3d7d899aff731d7fd Mon Sep 17 00:00:00 2001 From: AllanM84 <118641007+AllanM84@users.noreply.github.com> Date: Wed, 14 Aug 2024 04:50:10 +1000 Subject: [PATCH 15/23] Update inputXML.xaml (#2558) Change to line 654 from {SearchBarTextBoxFontSize} to 12. This now now allows the text to display correctly in the text box. Change to line 666 from 16 to 180 for the margin. This now allows text to be visible when searching, also positions the magnify glass to the right side of the text box. Change to line 678 from 193 to 205, which now places the clear button (X) on the outside of the text box for clearing the text in the textbox. --- xaml/inputXML.xaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/xaml/inputXML.xaml b/xaml/inputXML.xaml index 7441cc1f..639c95fb 100644 --- a/xaml/inputXML.xaml +++ b/xaml/inputXML.xaml @@ -647,23 +647,25 @@ Consider using a Math Solver, will help in making development of these things much easier --> + <!-- Changed the font size from {SearchBarTextBoxFontSize} to 12. This now display the text box correctly in the text box.--> <TextBox Grid.Column="0" Width="{SearchBarWidth}" Height="{SearchBarHeight}" - FontSize="{SearchBarTextBoxFontSize}" + FontSize="12" VerticalAlignment="Center" HorizontalAlignment="Left" BorderThickness="1" Name="SearchBar" Foreground="{MainForegroundColor}" Background="{MainBackgroundColor}" ToolTip="Press Ctrl-F and type app name to filter application list below. Press Esc to reset the filter"> </TextBox> + <!--Changed the margin from 16 to 180, which now places the magnifying glass icon on the right side of the text box. Now able to see what is been searched for.--> <TextBlock Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" FontFamily="Segoe MDL2 Assets" FontSize="{IconFontSize}" - Margin="16,0,0,0">&#xE721;</TextBlock> + Margin="180,0,0,0">&#xE721;</TextBlock> <!-- TODO: Make this ClearButton Positioning react to @@ -671,11 +673,12 @@ Consider using a Math Solver, will help in making development of these things much easier --> + <!-- changed the {SearchBarClearButtonMargin} value from 193 to 205, which now places the clear button on the outside of the text box. --> <Button Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Name="SearchBarClearButton" Style="{StaticResource SearchBarClearButtonStyle}" - Margin="193,0,0,0" Visibility="Collapsed"/> + Margin="205,0,0,0" Visibility="Collapsed"/> <ProgressBar Grid.Column="1" From fa17abdd4983810fd4b126170888d18c524a01d2 Mon Sep 17 00:00:00 2001 From: Chris Titus <contact@christitus.com> Date: Wed, 14 Aug 2024 09:14:46 -0500 Subject: [PATCH 16/23] Create SECURITY.md --- SECURITY.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..6b437033 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,5 @@ +# Security Policy + +If you find a security issue please make post it in the issues tab. If you think it should be private you can email me at contact@christitus.com. + +For immediate response check out our discord server @ [![](https://dcbadge.limes.pink/api/server/https://discord.gg/RUbZUZyByQ?theme=default-inverted&style=for-the-badge)](https://discord.gg/RUbZUZyByQ) From 17d523d8f8188bf5b40adf5d1f000c48b9b27b84 Mon Sep 17 00:00:00 2001 From: Chris Titus <contact@christitus.com> Date: Wed, 14 Aug 2024 10:23:26 -0500 Subject: [PATCH 17/23] change file structure --- CONTRIBUTING.md => .github/CONTRIBUTING.md | 0 LICENSE => .github/LICENSE | 0 SECURITY.md => .github/SECURITY.md | 0 mkdocs.yml => .github/mkdocs.yml | 0 requirements.txt => .github/requirements.txt | 0 .github/workflows/github-pages.yaml | 6 ++-- autounattend.xml => config/autounattend.xml | 0 gpedit-home.ps1 | 4 --- .../devdocs-generator.ps1 | 28 +++++++++---------- 9 files changed, 17 insertions(+), 21 deletions(-) rename CONTRIBUTING.md => .github/CONTRIBUTING.md (100%) rename LICENSE => .github/LICENSE (100%) rename SECURITY.md => .github/SECURITY.md (100%) rename mkdocs.yml => .github/mkdocs.yml (100%) rename requirements.txt => .github/requirements.txt (100%) rename autounattend.xml => config/autounattend.xml (100%) delete mode 100644 gpedit-home.ps1 rename devdocs-generator.ps1 => tools/devdocs-generator.ps1 (95%) diff --git a/CONTRIBUTING.md b/.github/CONTRIBUTING.md similarity index 100% rename from CONTRIBUTING.md rename to .github/CONTRIBUTING.md diff --git a/LICENSE b/.github/LICENSE similarity index 100% rename from LICENSE rename to .github/LICENSE diff --git a/SECURITY.md b/.github/SECURITY.md similarity index 100% rename from SECURITY.md rename to .github/SECURITY.md diff --git a/mkdocs.yml b/.github/mkdocs.yml similarity index 100% rename from mkdocs.yml rename to .github/mkdocs.yml diff --git a/requirements.txt b/.github/requirements.txt similarity index 100% rename from requirements.txt rename to .github/requirements.txt diff --git a/.github/workflows/github-pages.yaml b/.github/workflows/github-pages.yaml index f7d90060..b51697b8 100644 --- a/.github/workflows/github-pages.yaml +++ b/.github/workflows/github-pages.yaml @@ -24,8 +24,8 @@ jobs: python-version: 3.x # Install latest Stable release of Python 3 cache: 'pip' # caching pip dependencies - - name: Install Necessary Dependencies using 'pip install -r requirements.txt' - run: pip install -r requirements.txt + - name: Install Necessary Dependencies using 'pip install -r .github/requirements.txt' + run: pip install -r .github/requirements.txt - name: Build & Deploy using 'mkdocs' - run: mkdocs gh-deploy --force + run: mkdocs gh-deploy --force -f .github/mkdocs.yml \ No newline at end of file diff --git a/autounattend.xml b/config/autounattend.xml similarity index 100% rename from autounattend.xml rename to config/autounattend.xml diff --git a/gpedit-home.ps1 b/gpedit-home.ps1 deleted file mode 100644 index 43c552a3..00000000 --- a/gpedit-home.ps1 +++ /dev/null @@ -1,4 +0,0 @@ -Get-ChildItem @( - "$env:SystemRoot\servicing\Packages\Microsoft-Windows-GroupPolicy-ClientTools-Package*.mum", - "$env:SystemRoot\servicing\Packages\Microsoft-Windows-GroupPolicy-ClientExtensions-Package*.mum" -) | ForEach-Object { dism.exe /online /norestart /add-package:"$_" } diff --git a/devdocs-generator.ps1 b/tools/devdocs-generator.ps1 similarity index 95% rename from devdocs-generator.ps1 rename to tools/devdocs-generator.ps1 index 8f5f4081..792f6581 100644 --- a/devdocs-generator.ps1 +++ b/tools/devdocs-generator.ps1 @@ -563,17 +563,17 @@ function Add-LinkAttributeToJson { } Update-Progress "Loading JSON files" 10 -$tweaks = Get-Content -Path "config/tweaks.json" | ConvertFrom-Json -$features = Get-Content -Path "config/feature.json" | ConvertFrom-Json +$tweaks = Get-Content -Path "../config/tweaks.json" | ConvertFrom-Json +$features = Get-Content -Path "../config/feature.json" | ConvertFrom-Json Update-Progress "Getting last modified dates of the JSON files" 20 -$tweaksLastModified = (Get-Item "config/tweaks.json").LastWriteTime.ToString("yyyy-MM-dd") -$featuresLastModified = (Get-Item "config/feature.json").LastWriteTime.ToString("yyyy-MM-dd") +$tweaksLastModified = (Get-Item "../config/tweaks.json").LastWriteTime.ToString("yyyy-MM-dd") +$featuresLastModified = (Get-Item "../config/feature.json").LastWriteTime.ToString("yyyy-MM-dd") -$tweaksOutputDir = "docs/dev/tweaks" -$featuresOutputDir = "docs/dev/features" -$privateFunctionsDir = "functions/private" -$publicFunctionsDir = "functions/public" +$tweaksOutputDir = "../docs/dev/tweaks" +$featuresOutputDir = "../docs/dev/features" +$privateFunctionsDir = "../functions/private" +$publicFunctionsDir = "../functions/public" $functions = @{} $itemnametocut = "WPF(WinUtil|Toggle|Features?|Tweaks?|Panel|Fix(es)?)?" @@ -592,7 +592,7 @@ Load-Functions -dir $publicFunctionsDir Update-Progress "Adding documentation links to JSON files" 50 # Define the JSON file paths -$jsonPaths = @(".\config\feature.json", ".\config\tweaks.json") +$jsonPaths = @("../config/feature.json", "../config/tweaks.json") # Loop through each JSON file path foreach ($jsonPath in $jsonPaths) { @@ -612,12 +612,12 @@ foreach ($jsonPath in $jsonPaths) { Set-Content -Path $jsonPath -Value $jsonString } -Add-LinkAttributeToJson -jsonFilePath "config/tweaks.json" -outputDir "dev/tweaks" -Add-LinkAttributeToJson -jsonFilePath "config/feature.json" -outputDir "dev/features" +Add-LinkAttributeToJson -jsonFilePath "../config/tweaks.json" -outputDir "dev/tweaks" +Add-LinkAttributeToJson -jsonFilePath "../config/feature.json" -outputDir "dev/features" Update-Progress "Generating content for documentation" 60 -$tweakResult = Generate-MarkdownFiles -data $tweaks -outputDir $tweaksOutputDir -jsonFilePath "config/tweaks.json" -lastModified $tweaksLastModified -type "tweak" -initialProgress 60 -$featureResult = Generate-MarkdownFiles -data $features -outputDir $featuresOutputDir -jsonFilePath "config/feature.json" -lastModified $featuresLastModified -type "feature" -initialProgress 70 +$tweakResult = Generate-MarkdownFiles -data $tweaks -outputDir $tweaksOutputDir -jsonFilePath "../config/tweaks.json" -lastModified $tweaksLastModified -type "tweak" -initialProgress 60 +$featureResult = Generate-MarkdownFiles -data $features -outputDir $featuresOutputDir -jsonFilePath "../config/feature.json" -lastModified $featuresLastModified -type "feature" -initialProgress 70 Update-Progress "Generating table of contents" 80 $allTocEntries = $tweakResult.TocEntries + $featureResult.TocEntries @@ -639,6 +639,6 @@ $indexContent += Process-MultilineStrings @" \\ "@ $indexContent += $(Generate-TypeSectionContent $featureEntries) + "`r`n" -Set-Content -Path "docs/devdocs.md" -Value $indexContent -Encoding utf8 +Set-Content -Path "../docs/devdocs.md" -Value $indexContent -Encoding utf8 Update-Progress "Process Completed" 100 From 09eb4eaa009f2092b9dc4b86743f2c129565046f Mon Sep 17 00:00:00 2001 From: ChrisTitusTech <ChrisTitusTech@users.noreply.github.com> Date: Wed, 14 Aug 2024 15:31:03 +0000 Subject: [PATCH 18/23] =?UTF-8?q?Deploying=20to=20main=20from=20@=20ChrisT?= =?UTF-8?q?itusTech/winutil@17d523d8f8188bf5b40adf5d1f000c48b9b27b84=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c4cfa6ec..942a03d1 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ If you have Issues, refer to [Known Issues](https://christitustech.github.io/win These are the sponsors that help keep this project alive with monthly contributions. -<!-- sponsors --><a href="https://github.com/GregoryNavasarkian"><img src="https://github.com/GregoryNavasarkian.png" width="60px" alt="Gregory Navasarkian" /></a><a href="https://github.com/ysaito8015"><img src="https://github.com/ysaito8015.png" width="60px" alt="Yusuke Saito" /></a><a href="https://github.com/TriHydera"><img src="https://github.com/TriHydera.png" width="60px" alt="TriHydera" /></a><a href="https://github.com/jozozovko"><img src="https://github.com/jozozovko.png" width="60px" alt="" /></a><a href="https://github.com/DelDongo"><img src="https://github.com/DelDongo.png" width="60px" alt="" /></a><a href="https://github.com/markamos"><img src="https://github.com/markamos.png" width="60px" alt="Mark Amos" /></a><a href="https://github.com/dwelfusius"><img src="https://github.com/dwelfusius.png" width="60px" alt="" /></a><a href="https://github.com/mews-se"><img src="https://github.com/mews-se.png" width="60px" alt="" /></a><a href="https://github.com/jdiegmueller"><img src="https://github.com/jdiegmueller.png" width="60px" alt="Jason A. Diegmueller" /></a><a href="https://github.com/AlanTristar"><img src="https://github.com/AlanTristar.png" width="60px" alt="" /></a><a href="https://github.com/JennJones89"><img src="https://github.com/JennJones89.png" width="60px" alt="" /></a><a href="https://github.com/zepled112"><img src="https://github.com/zepled112.png" width="60px" alt="wyatt" /></a><a href="https://github.com/altugtekiner"><img src="https://github.com/altugtekiner.png" width="60px" alt="" /></a><a href="https://github.com/getsmor"><img src="https://github.com/getsmor.png" width="60px" alt="" /></a><a href="https://github.com/robertsandrock"><img src="https://github.com/robertsandrock.png" width="60px" alt="" /></a><a href="https://github.com/jeffnesbit"><img src="https://github.com/jeffnesbit.png" width="60px" alt="" /></a><a href="https://github.com/mmomega"><img src="https://github.com/mmomega.png" width="60px" alt="" /></a><a href="https://github.com/KenichiQaz"><img src="https://github.com/KenichiQaz.png" width="60px" alt="Stefan" /></a><a href="https://github.com/thaddl"><img src="https://github.com/thaddl.png" width="60px" alt="thaddl" /></a><a href="https://github.com/paulsheets"><img src="https://github.com/paulsheets.png" width="60px" alt="Paul" /></a><a href="https://github.com/djones369"><img src="https://github.com/djones369.png" width="60px" alt="Dave Jones" /></a><a href="https://github.com/anthonymendez"><img src="https://github.com/anthonymendez.png" width="60px" alt="Anthony Mendez" /></a><a href="https://github.com/woobe-studio"><img src="https://github.com/woobe-studio.png" width="60px" alt="Michael Wozniak" /></a><a href="https://github.com/xBandaku"><img src="https://github.com/xBandaku.png" width="60px" alt="xPandaku" /></a><!-- sponsors --> +<!-- sponsors --><a href="https://github.com/ysaito8015"><img src="https://github.com/ysaito8015.png" width="60px" alt="Yusuke Saito" /></a><a href="https://github.com/TriHydera"><img src="https://github.com/TriHydera.png" width="60px" alt="TriHydera" /></a><a href="https://github.com/jozozovko"><img src="https://github.com/jozozovko.png" width="60px" alt="" /></a><a href="https://github.com/DelDongo"><img src="https://github.com/DelDongo.png" width="60px" alt="" /></a><a href="https://github.com/markamos"><img src="https://github.com/markamos.png" width="60px" alt="Mark Amos" /></a><a href="https://github.com/dwelfusius"><img src="https://github.com/dwelfusius.png" width="60px" alt="" /></a><a href="https://github.com/mews-se"><img src="https://github.com/mews-se.png" width="60px" alt="" /></a><a href="https://github.com/jdiegmueller"><img src="https://github.com/jdiegmueller.png" width="60px" alt="Jason A. Diegmueller" /></a><a href="https://github.com/AlanTristar"><img src="https://github.com/AlanTristar.png" width="60px" alt="" /></a><a href="https://github.com/JennJones89"><img src="https://github.com/JennJones89.png" width="60px" alt="" /></a><a href="https://github.com/zepled112"><img src="https://github.com/zepled112.png" width="60px" alt="wyatt" /></a><a href="https://github.com/altugtekiner"><img src="https://github.com/altugtekiner.png" width="60px" alt="" /></a><a href="https://github.com/getsmor"><img src="https://github.com/getsmor.png" width="60px" alt="" /></a><a href="https://github.com/robertsandrock"><img src="https://github.com/robertsandrock.png" width="60px" alt="" /></a><a href="https://github.com/jeffnesbit"><img src="https://github.com/jeffnesbit.png" width="60px" alt="" /></a><a href="https://github.com/mmomega"><img src="https://github.com/mmomega.png" width="60px" alt="" /></a><a href="https://github.com/KenichiQaz"><img src="https://github.com/KenichiQaz.png" width="60px" alt="Stefan" /></a><a href="https://github.com/thaddl"><img src="https://github.com/thaddl.png" width="60px" alt="thaddl" /></a><a href="https://github.com/paulsheets"><img src="https://github.com/paulsheets.png" width="60px" alt="Paul" /></a><a href="https://github.com/djones369"><img src="https://github.com/djones369.png" width="60px" alt="Dave Jones" /></a><a href="https://github.com/anthonymendez"><img src="https://github.com/anthonymendez.png" width="60px" alt="Anthony Mendez" /></a><a href="https://github.com/woobe-studio"><img src="https://github.com/woobe-studio.png" width="60px" alt="Michael Wozniak" /></a><a href="https://github.com/xBandaku"><img src="https://github.com/xBandaku.png" width="60px" alt="xPandaku" /></a><!-- sponsors --> ## 🏅 Thanks to all Contributors Thanks a lot for spending your time helping Winutil grow. Thanks a lot! Keep rocking 🍻. From 863dd83faa609fa05b85e2294a8b92bbc667ef0d Mon Sep 17 00:00:00 2001 From: Chris Titus <contact@christitus.com> Date: Wed, 14 Aug 2024 10:34:19 -0500 Subject: [PATCH 19/23] Update mkdocs.yml --- .github/mkdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/mkdocs.yml b/.github/mkdocs.yml index 5569666e..02cd7d8f 100644 --- a/.github/mkdocs.yml +++ b/.github/mkdocs.yml @@ -12,7 +12,7 @@ nav: theme: name: material - custom_dir: 'overrides' + custom_dir: '../overrides' features: - navigation.tabs - navigation.sections From 67be99bb7bc71cd6669b881d4cff2ead4d9554b6 Mon Sep 17 00:00:00 2001 From: Chris Titus <contact@christitus.com> Date: Wed, 14 Aug 2024 10:54:52 -0500 Subject: [PATCH 20/23] Update mkdocs.yml --- .github/mkdocs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/mkdocs.yml b/.github/mkdocs.yml index 02cd7d8f..c4a6aa2c 100644 --- a/.github/mkdocs.yml +++ b/.github/mkdocs.yml @@ -13,6 +13,7 @@ nav: theme: name: material custom_dir: '../overrides' + docs_dir: '../docs' features: - navigation.tabs - navigation.sections From d0fa506e4fadb17a682b90f98d7f44c306dc5282 Mon Sep 17 00:00:00 2001 From: Chris Titus <contact@christitus.com> Date: Wed, 14 Aug 2024 10:58:33 -0500 Subject: [PATCH 21/23] Update mkdocs.yml --- .github/mkdocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/mkdocs.yml b/.github/mkdocs.yml index c4a6aa2c..a4c7dfe2 100644 --- a/.github/mkdocs.yml +++ b/.github/mkdocs.yml @@ -1,4 +1,5 @@ site_name: WinUtil Documentation +docs_dir: '../docs' repo_url: https://github.com/ChrisTitusTech/winutil nav: @@ -13,7 +14,6 @@ nav: theme: name: material custom_dir: '../overrides' - docs_dir: '../docs' features: - navigation.tabs - navigation.sections From b0d54e41ad86ed973d95ada0b69aa6316d577f44 Mon Sep 17 00:00:00 2001 From: Chris Titus <contact@christitus.com> Date: Wed, 14 Aug 2024 13:54:10 -0500 Subject: [PATCH 22/23] Update contribute.md --- docs/contribute.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/contribute.md b/docs/contribute.md index c93fd74c..457c880c 100644 --- a/docs/contribute.md +++ b/docs/contribute.md @@ -1,3 +1,3 @@ ---8<-- "CONTRIBUTING.md" +--8<-- ".github/CONTRIBUTING.md" <!-- The content is sourced from "CONTRIBUTING.md," located in the root directory of the project. --> From 4d2ea15e190e44eec655b9483a58ef521573d440 Mon Sep 17 00:00:00 2001 From: CodingWonders <101426328+CodingWonders@users.noreply.github.com> Date: Wed, 14 Aug 2024 21:31:24 +0200 Subject: [PATCH 23/23] [MicroWin] Add try-catch block for AppX packages (#2560) --- .../private/Invoke-WinUtilMicroWin-Helper.ps1 | 71 ++++++++++--------- 1 file changed, 39 insertions(+), 32 deletions(-) diff --git a/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 b/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 index bdd843f8..3f473d85 100644 --- a/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 +++ b/functions/private/Invoke-WinUtilMicroWin-Helper.ps1 @@ -132,42 +132,49 @@ function Remove-ProvisionedPackages() { .EXAMPLE Remove-ProvisionedPackages #> - $appxProvisionedPackages = Get-AppxProvisionedPackage -Path "$($scratchDir)" | Where-Object { - $_.PackageName -NotLike "*AppInstaller*" -AND - $_.PackageName -NotLike "*Store*" -and - $_.PackageName -NotLike "*dism*" -and - $_.PackageName -NotLike "*Foundation*" -and - $_.PackageName -NotLike "*FodMetadata*" -and - $_.PackageName -NotLike "*LanguageFeatures*" -and - $_.PackageName -NotLike "*Notepad*" -and - $_.PackageName -NotLike "*Printing*" -and - $_.PackageName -NotLike "*Wifi*" -and - $_.PackageName -NotLike "*Foundation*" -and - $_.PackageName -NotLike "*YourPhone*" -and - $_.PackageName -NotLike "*Xbox*" -and - $_.PackageName -NotLike "*WindowsTerminal*" -and - $_.PackageName -NotLike "*Calculator*" -and - $_.PackageName -NotLike "*Photos*" -and - $_.PackageName -NotLike "*VCLibs*" -and - $_.PackageName -NotLike "*Paint*" -and - $_.PackageName -NotLike "*Gaming*" -and - $_.PackageName -NotLike "*Extension*" -and - $_.PackageName -NotLike "*SecHealthUI*" - + try + { + $appxProvisionedPackages = Get-AppxProvisionedPackage -Path "$($scratchDir)" | Where-Object { + $_.PackageName -NotLike "*AppInstaller*" -AND + $_.PackageName -NotLike "*Store*" -and + $_.PackageName -NotLike "*dism*" -and + $_.PackageName -NotLike "*Foundation*" -and + $_.PackageName -NotLike "*FodMetadata*" -and + $_.PackageName -NotLike "*LanguageFeatures*" -and + $_.PackageName -NotLike "*Notepad*" -and + $_.PackageName -NotLike "*Printing*" -and + $_.PackageName -NotLike "*Wifi*" -and + $_.PackageName -NotLike "*Foundation*" -and + $_.PackageName -NotLike "*YourPhone*" -and + $_.PackageName -NotLike "*Xbox*" -and + $_.PackageName -NotLike "*WindowsTerminal*" -and + $_.PackageName -NotLike "*Calculator*" -and + $_.PackageName -NotLike "*Photos*" -and + $_.PackageName -NotLike "*VCLibs*" -and + $_.PackageName -NotLike "*Paint*" -and + $_.PackageName -NotLike "*Gaming*" -and + $_.PackageName -NotLike "*Extension*" -and + $_.PackageName -NotLike "*SecHealthUI*" } - $counter = 0 - foreach ($appx in $appxProvisionedPackages) { - $status = "Removing Provisioned $($appx.PackageName)" - Write-Progress -Activity "Removing Provisioned Apps" -Status $status -PercentComplete ($counter++/$appxProvisionedPackages.Count*100) - try { - Remove-AppxProvisionedPackage -Path "$scratchDir" -PackageName $appx.PackageName -ErrorAction SilentlyContinue - } catch { - Write-Host "Application $($appx.PackageName) could not be removed" - continue + $counter = 0 + foreach ($appx in $appxProvisionedPackages) { + $status = "Removing Provisioned $($appx.PackageName)" + Write-Progress -Activity "Removing Provisioned Apps" -Status $status -PercentComplete ($counter++/$appxProvisionedPackages.Count*100) + try { + Remove-AppxProvisionedPackage -Path "$scratchDir" -PackageName $appx.PackageName -ErrorAction SilentlyContinue + } catch { + Write-Host "Application $($appx.PackageName) could not be removed" + continue + } } + Write-Progress -Activity "Removing Provisioned Apps" -Status "Ready" -Completed + } + catch + { + # This can happen if getting AppX packages fails + Write-Host "Unable to get information about the AppX packages. MicroWin processing will continue, but AppX packages will not be processed" } - Write-Progress -Activity "Removing Provisioned Apps" -Status "Ready" -Completed } function Copy-ToUSB([string]$fileToCopy) {