From a3e8c0978ca9efe2580b86b05f78f2df9ba3c895 Mon Sep 17 00:00:00 2001
From: andrewj-t <67892040+andrewj-t@users.noreply.github.com>
Date: Thu, 26 Dec 2024 14:43:53 +0800
Subject: [PATCH 1/2] Added fix for desktop background being overwritten by
Spotlight
---
AutopilotBranding/AutopilotBranding.ps1 | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/AutopilotBranding/AutopilotBranding.ps1 b/AutopilotBranding/AutopilotBranding.ps1
index d8aa42b..8ba4639 100644
--- a/AutopilotBranding/AutopilotBranding.ps1
+++ b/AutopilotBranding/AutopilotBranding.ps1
@@ -65,6 +65,10 @@ reg.exe add "HKLM\TempUser\Software\Microsoft\Windows\CurrentVersion\Explorer\Ad
# STEP 2B: Hide "Learn more about this picture" from the desktop
reg.exe add "HKLM\TempUser\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" /v "{2cc5ca98-6485-489a-920e-b3e88a6ccce3}" /t REG_DWORD /d 1 /f | Out-Host
+# STEP 3C: Disable Windows Spotlight as per https://github.com/mtniehaus/AutopilotBranding/issues/13#issuecomment-2449224828
+Log "Disabling Windows Spotlight for Desktop"
+reg.exe add "HKLM\TempUser\Software\Policies\Microsoft\Windows\CloudContent" /v DisableSpotlightCollectionOnDesktop /t REG_DWORD /d 1 /f | Out-Host
+
reg.exe unload HKLM\TempUser | Out-Host
# STEP 3: Set time zone (if specified)
From 787c38453ffa8c15e40c9da8f25c253782e371a2 Mon Sep 17 00:00:00 2001
From: andrewj-t <67892040+andrewj-t@users.noreply.github.com>
Date: Thu, 26 Dec 2024 14:56:09 +0800
Subject: [PATCH 2/2] Added support for removing capabilities and optional
features
---
AutopilotBranding/AutopilotBranding.ps1 | 26 ++++++++++++++++++++++++-
AutopilotBranding/Config.xml | 12 ++++++++++++
README.md | 9 ++++++---
3 files changed, 43 insertions(+), 4 deletions(-)
diff --git a/AutopilotBranding/AutopilotBranding.ps1 b/AutopilotBranding/AutopilotBranding.ps1
index 8ba4639..4ed754f 100644
--- a/AutopilotBranding/AutopilotBranding.ps1
+++ b/AutopilotBranding/AutopilotBranding.ps1
@@ -124,7 +124,7 @@ if ($config.Config.Language) {
& $env:SystemRoot\System32\control.exe "intl.cpl,,/f:`"$($installFolder)$($config.Config.Language)`""
}
-# STEP 9: Add features on demand
+# STEP 9: Add features on demand, Disable Optional Features, Remove Windows Capabilities
$currentWU = (Get-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate\AU" -ErrorAction Ignore).UseWuServer
if ($currentWU -eq 1)
{
@@ -132,6 +132,7 @@ if ($currentWU -eq 1)
Set-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "UseWuServer" -Value 0
Restart-Service wuauserv
}
+# Step 9A: Add features on demand
if ($config.Config.AddFeatures.Feature.Count -gt 0)
{
$config.Config.AddFeatures.Feature | % {
@@ -139,6 +140,29 @@ if ($config.Config.AddFeatures.Feature.Count -gt 0)
Add-WindowsCapability -Online -Name $_ -ErrorAction SilentlyContinue | Out-Null
}
}
+# Step 9B: Disable Optional features
+if ($config.Config.DisableOptionalFeatures.Feature.Count -gt 0)
+{
+ $EnabledOptionalFeatures = Get-WindowsOptionalFeature -Online | Where-Object {$_.State -eq "Enabled"}
+ foreach ($EnabledFeature in $EnabledOptionalFeatures) {
+ if ($config.Config.DisableOptionalFeatures.Feature -contains $EnabledFeature.FeatureName) {
+ Log "Disabling Optional Feature: $($EnabledFeature.FeatureName)"
+ Disable-WindowsOptionalFeature -Online -FeatureName $EnabledFeature.FeatureName -NoRestart | Out-Null
+ }
+ }
+}
+# Step 9C: Remove Windows Capabilities
+if ($config.Config.RemoveCapability.Capability.Count -gt 0)
+{
+ $InstalledCapabilities = Get-WindowsCapability -Online | Where-Object {$_.State -eq "Installed"}
+ foreach ($InstalledCapability in $InstalledCapabilities) {
+ if ($config.Config.RemoveCapability.Capability -contains $InstalledCapability.Name.Split("~")[0]) {
+ Log "Removing Windows Capability: $($InstalledCapability.Name)"
+ Remove-WindowsCapability -Online -Name $InstalledCapability.Name | Out-Null
+ }
+ }
+}
+
if ($currentWU -eq 1)
{
Log "Turning on WSUS"
diff --git a/AutopilotBranding/Config.xml b/AutopilotBranding/Config.xml
index 089abd0..e479b6d 100644
--- a/AutopilotBranding/Config.xml
+++ b/AutopilotBranding/Config.xml
@@ -42,6 +42,18 @@
-->
WMIC
+
+
+ MicrosoftWindowsPowershellV2Root
+ WorkFolders-Client
+ Recall
+ MediaPlayback
+
+
+
+ App.StepsRecorder
+ Microsoft.Windows.PowerShell.ISE
+
Associations.xml
diff --git a/README.md b/README.md
index 3cce587..cc08be3 100644
--- a/README.md
+++ b/README.md
@@ -15,6 +15,8 @@ These customizations are currently supported:
- Disable the Edge desktop icon. When using OneDrive Known Folder Move, this can cause duplicate (and unnecessary) shortcuts to be synced.
- Install language packs. You can embed language pack CAB files into the MSI (place them into the LPs folder), and each will be automatically installed. (In a perfect world, these would be pulled from Windows Update, but there's no simple way to do that, hence the need to include these in the MSI. You can download the language pack ISO from MSDN or VLSC.)
- Install features on demand (FOD). Specify a list of features that you want to install, from the list at https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/features-on-demand-non-language-fod. The needed components will be downloaded from Windows Update automatically and added to the running OS.
+- Remove features on demand (FOD). Specify a list of preinstalled Features on Demand to remove by their Capability Name, excluding the tilde characters and version number. Capability Names can be retrieved by running `Get-WindowsCapability -Online`
+- Disable Optional Features. Specify a list of optional features to disable by per their Feature Name. Feature Names can be retrieved by running `Get-WindowsOptionalFeature -Online`
- Configure language settings. Adding a language pack isn't enough - you have to tell Windows that you want it to be configured for all users. This is done through an XML file fed to INTL.CPL; customize the file as needed. (Note this is commented out by default in the Config.xml file.)
- Configure default apps. Import a list of file associations (as created by manually configuring the associations that you want and then using "DISM /Online /Export-DefaultAppAssociations:C:\Associations.xml" to export those settings) that should replace the default app associations. (Note that even though an example is included from a customized Windows 10 1903 image, making IE 11 the default browser, you should replace this file with your own exported version. Also, do not edit the file that you exported, e.g. to remove entries that you didn't change.)
@@ -45,9 +47,10 @@ See https://oofhours.com/2020/05/18/two-for-one-updated-autopilot-branding-and-u
## Change history
-2023-09-23: Added logic to handle the Windows 11 Start menu proces using Start2.bin; Windows 10 will continue to use Layout.xml. Added additional Windows 11 in-box apps to remove.
-2024-01-31: Added additional apps to remove, adding timestamps to log messages, cleaned up error logging.
-2024-04-27: Added logic to stop the Start menu from popping up each time a new user signs in.
+- 2023-09-23: Added logic to handle the Windows 11 Start menu proces using Start2.bin; Windows 10 will continue to use Layout.xml. Added additional Windows 11 in-box apps to remove.
+- 2024-01-31: Added additional apps to remove, adding timestamps to log messages, cleaned up error logging.
+- 2024-04-27: Added logic to stop the Start menu from popping up each time a new user signs in.
+- 2024-12-26: Added support for removing FODs and disabling optional features.
## Suggestions?