Skip to content

Commit af81951

Browse files
committed
Merge PR ntdevlabs#465: add custom package removal mode
2 parents 61da06d + 4e79da5 commit af81951

1 file changed

Lines changed: 73 additions & 18 deletions

File tree

‎tiny11maker.ps1‎

Lines changed: 73 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@
1414
Drive letter of the desired scratch disk (eg: D)
1515
NOTE: The SCRATCH drive must support file/folder security (i.e., must be, e.g., NTFS filesystem).
1616
17+
.PARAMETER Custom
18+
Optional switch to manually choose which provisioned packages should be removed.
19+
1720
.EXAMPLE
1821
.\tiny11maker.ps1 E D
1922
.\tiny11maker.ps1 -ISO E -SCRATCH D
2023
.\tiny11maker.ps1 -SCRATCH D -ISO E
24+
.\tiny11maker.ps1 -SCRATCH D -ISO E -Custom
2125
.\tiny11maker.ps1
2226
2327
*If you ordinal parameters the first one must be the mounted iso. The second is the scratch drive.
@@ -31,7 +35,8 @@
3135
#---------[ Parameters ]---------#
3236
param (
3337
[ValidatePattern('^[c-zC-Z]$')][string]$ISO,
34-
[ValidatePattern('^[c-zC-Z]$')][string]$SCRATCH
38+
[ValidatePattern('^[c-zC-Z]$')][string]$SCRATCH,
39+
[switch]$Custom
3540
)
3641

3742
$ErrorActionPreference = 'Stop'
@@ -301,10 +306,47 @@ if (Test-Path -Path $packageFile -PathType Leaf) {
301306
}
302307
}
303308

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+
}
307348
}
349+
308350
foreach ($package in $packagesToRemove) {
309351
Write-Host "Removing $package..."
310352
Remove-AppxProvisionedPackage -Path "$ScratchDisk\scratchdir" -PackageName "$package" | Out-Null
@@ -423,23 +465,36 @@ Set-RegistryValue 'HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\Conten
423465
Set-RegistryValue 'HKLM\zNTUSER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager' 'SubscribedContent-338387Enabled' 'REG_DWORD' '0'
424466
## Prevents installation of DevHome and Outlook
425467

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+
}
432480

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+
}
437486

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+
}
440493

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+
}
443498

444499
Write-Host "=== Deleting scheduled task definition files..."
445500
$tasksPath = "$ScratchDisk\scratchdir\Windows\System32\Tasks"

0 commit comments

Comments
 (0)