|
14 | 14 | Drive letter of the desired scratch disk (eg: D) |
15 | 15 | NOTE: The SCRATCH drive must support file/folder security (i.e., must be, e.g., NTFS filesystem). |
16 | 16 |
|
| 17 | +.PARAMETER Custom |
| 18 | + Optional switch to manually choose which provisioned packages should be removed. |
| 19 | +
|
17 | 20 | .EXAMPLE |
18 | 21 | .\tiny11maker.ps1 E D |
19 | 22 | .\tiny11maker.ps1 -ISO E -SCRATCH D |
20 | 23 | .\tiny11maker.ps1 -SCRATCH D -ISO E |
| 24 | + .\tiny11maker.ps1 -SCRATCH D -ISO E -Custom |
21 | 25 | .\tiny11maker.ps1 |
22 | 26 |
|
23 | 27 | *If you ordinal parameters the first one must be the mounted iso. The second is the scratch drive. |
|
31 | 35 | #---------[ Parameters ]---------# |
32 | 36 | param ( |
33 | 37 | [ValidatePattern('^[c-zC-Z]$')][string]$ISO, |
34 | | - [ValidatePattern('^[c-zC-Z]$')][string]$SCRATCH |
| 38 | + [ValidatePattern('^[c-zC-Z]$')][string]$SCRATCH, |
| 39 | + [switch]$Custom |
35 | 40 | ) |
36 | 41 |
|
37 | 42 | $ErrorActionPreference = 'Stop' |
@@ -301,10 +306,47 @@ if (Test-Path -Path $packageFile -PathType Leaf) { |
301 | 306 | } |
302 | 307 | } |
303 | 308 |
|
304 | | -$packagesToRemove = $packages | Where-Object { |
305 | | - $packageName = $_ |
306 | | - $packagePrefixes -contains ($packagePrefixes | Where-Object { $packageName -like "*$_*" }) |
| 309 | +if ($Custom) { |
| 310 | + $packagesToRemove = @() |
| 311 | + |
| 312 | + while ($true) { |
| 313 | + Write-Output "List of provisioned applications available for removal:" |
| 314 | + for ($i = 0; $i -lt $packages.Count; $i++) { |
| 315 | + Write-Output "$($i + 1). $($packages[$i])" |
| 316 | + } |
| 317 | + |
| 318 | + $userInput = Read-Host "Select application numbers (e.g. 1,3,5)" |
| 319 | + $selectedIndices = $userInput -split ',' | ForEach-Object { $_.Trim() } |
| 320 | + $packagesToRemove = @() |
| 321 | + |
| 322 | + foreach ($selectedIndex in $selectedIndices) { |
| 323 | + if ($selectedIndex -match '^\d+$' -and [int]$selectedIndex -ge 1 -and [int]$selectedIndex -le $packages.Count) { |
| 324 | + $packagesToRemove += $packages[[int]$selectedIndex - 1] |
| 325 | + } |
| 326 | + } |
| 327 | + |
| 328 | + $packagesToRemove = $packagesToRemove | Sort-Object -Unique |
| 329 | + |
| 330 | + if ($packagesToRemove.Count -eq 0) { |
| 331 | + Write-Output "No valid application selection detected. Please try again." |
| 332 | + continue |
| 333 | + } |
| 334 | + |
| 335 | + Write-Output "Chosen applications for removal:" |
| 336 | + $packagesToRemove | ForEach-Object { Write-Output " - $_" } |
| 337 | + |
| 338 | + $confirmation = Read-Host "Type 'yes' to confirm, or press Enter to reselect" |
| 339 | + if ($confirmation -match '^(?i:yes|y)$') { |
| 340 | + break |
| 341 | + } |
| 342 | + } |
| 343 | +} else { |
| 344 | + $packagesToRemove = $packages | Where-Object { |
| 345 | + $packageName = $_ |
| 346 | + $packagePrefixes -contains ($packagePrefixes | Where-Object { $packageName -like "*$_*" }) |
| 347 | + } |
307 | 348 | } |
| 349 | + |
308 | 350 | foreach ($package in $packagesToRemove) { |
309 | 351 | Write-Host "Removing $package..." |
310 | 352 | Remove-AppxProvisionedPackage -Path "$ScratchDisk\scratchdir" -PackageName "$package" | Out-Null |
@@ -423,23 +465,36 @@ Set-RegistryValue 'HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\Conten |
423 | 465 | Set-RegistryValue 'HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager' 'SubscribedContent-338387Enabled' 'REG_DWORD' '0' |
424 | 466 | ## Prevents installation of DevHome and Outlook |
425 | 467 |
|
426 | | -Write-Output "=== Prevents installation of DevHome and Outlook:" |
427 | | -Set-RegistryValue 'HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Orchestrator\UScheduler_Oobe\OutlookUpdate' 'workCompleted' 'REG_DWORD' '1' |
428 | | -Set-RegistryValue 'HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Orchestrator\UScheduler\OutlookUpdate' 'workCompleted' 'REG_DWORD' '1' |
429 | | -Set-RegistryValue 'HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Orchestrator\UScheduler\DevHomeUpdate' 'workCompleted' 'REG_DWORD' '1' |
430 | | -Remove-RegistryValue 'HKLM\zSOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\OutlookUpdate' |
431 | | -Remove-RegistryValue 'HKLM\zSOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\DevHomeUpdate' |
| 468 | +$devHomeSelected = $packagesToRemove | Where-Object { $_ -like '*Microsoft.Windows.DevHome*' } |
| 469 | +$outlookSelected = $packagesToRemove | Where-Object { $_ -like '*Microsoft.OutlookForWindows*' } |
| 470 | +$copilotSelected = $packagesToRemove | Where-Object { $_ -like '*Microsoft.Windows.Copilot*' -or $_ -like '*Microsoft.Copilot*' } |
| 471 | +$teamsSelected = $packagesToRemove | Where-Object { $_ -like '*Microsoft.Windows.Teams*' -or $_ -like '*MicrosoftTeams*' -or $_ -like '*MSTeams*' } |
| 472 | + |
| 473 | +if (-not $Custom -or $outlookSelected) { |
| 474 | + Write-Output "=== Prevent installation of New Outlook:" |
| 475 | + Set-RegistryValue 'HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Orchestrator\UScheduler_Oobe\OutlookUpdate' 'workCompleted' 'REG_DWORD' '1' |
| 476 | + Set-RegistryValue 'HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Orchestrator\UScheduler\OutlookUpdate' 'workCompleted' 'REG_DWORD' '1' |
| 477 | + Remove-RegistryValue 'HKLM\zSOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\OutlookUpdate' |
| 478 | + Set-RegistryValue 'HKLM\zSOFTWARE\Policies\Microsoft\Windows\Windows Mail' 'PreventRun' 'REG_DWORD' '1' |
| 479 | +} |
432 | 480 |
|
433 | | -Write-Output "=== Disabling Copilot" |
434 | | -Set-RegistryValue 'HKLM\zSOFTWARE\Policies\Microsoft\Windows\WindowsCopilot' 'TurnOffWindowsCopilot' 'REG_DWORD' '1' |
435 | | -Set-RegistryValue 'HKLM\zSOFTWARE\Policies\Microsoft\Edge' 'HubsSidebarEnabled' 'REG_DWORD' '0' |
436 | | -Set-RegistryValue 'HKLM\zSOFTWARE\Policies\Microsoft\Windows\Explorer' 'DisableSearchBoxSuggestions' 'REG_DWORD' '1' |
| 481 | +if (-not $Custom -or $devHomeSelected) { |
| 482 | + Write-Output "=== Prevents installation of DevHome:" |
| 483 | + Set-RegistryValue 'HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Orchestrator\UScheduler\DevHomeUpdate' 'workCompleted' 'REG_DWORD' '1' |
| 484 | + Remove-RegistryValue 'HKLM\zSOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\DevHomeUpdate' |
| 485 | +} |
437 | 486 |
|
438 | | -Write-Output "=== Prevents installation of Teams:" |
439 | | -Set-RegistryValue 'HKLM\zSOFTWARE\Policies\Microsoft\Teams' 'DisableInstallation' 'REG_DWORD' '1' |
| 487 | +if (-not $Custom -or $copilotSelected) { |
| 488 | + Write-Output "=== Disabling Copilot" |
| 489 | + Set-RegistryValue 'HKLM\zSOFTWARE\Policies\Microsoft\Windows\WindowsCopilot' 'TurnOffWindowsCopilot' 'REG_DWORD' '1' |
| 490 | + Set-RegistryValue 'HKLM\zSOFTWARE\Policies\Microsoft\Edge' 'HubsSidebarEnabled' 'REG_DWORD' '0' |
| 491 | + Set-RegistryValue 'HKLM\zSOFTWARE\Policies\Microsoft\Windows\Explorer' 'DisableSearchBoxSuggestions' 'REG_DWORD' '1' |
| 492 | +} |
440 | 493 |
|
441 | | -Write-Output "=== Prevent installation of New Outlook:" |
442 | | -Set-RegistryValue 'HKLM\zSOFTWARE\Policies\Microsoft\Windows\Windows Mail' 'PreventRun' 'REG_DWORD' '1' |
| 494 | +if (-not $Custom -or $teamsSelected) { |
| 495 | + Write-Output "=== Prevents installation of Teams:" |
| 496 | + Set-RegistryValue 'HKLM\zSOFTWARE\Policies\Microsoft\Teams' 'DisableInstallation' 'REG_DWORD' '1' |
| 497 | +} |
443 | 498 |
|
444 | 499 | Write-Host "=== Deleting scheduled task definition files..." |
445 | 500 | $tasksPath = "$ScratchDisk\scratchdir\Windows\System32\Tasks" |
|
0 commit comments