Skip to content

Commit dd749cc

Browse files
committed
refactor: trim unused module exports and tighten script modules
1 parent b835303 commit dd749cc

File tree

7 files changed

+46
-146
lines changed

7 files changed

+46
-146
lines changed

src/playbook/Executables/AtlasModules/Scripts/Modules/Debloat/Debloat.psm1

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,4 @@ function Set-DisabledScheduledTasks {
6363
Disable-ScheduledTask -TaskPath "\Microsoft\Windows\Flighting\FeatureConfig\" -TaskName "UsageDataReporting" -ErrorAction SilentlyContinue
6464
}
6565

66-
function Invoke-AllDebloatOptimizations {
67-
Write-Host "Running debloat optimizations"
68-
Set-ContentDelivery
69-
Set-StorageSense
70-
Set-DisableStorageSense
71-
Set-DisabledScheduledTasks
72-
}
73-
74-
Export-ModuleMember -Function Invoke-AllDebloatOptimizations
66+
Export-ModuleMember -Function @()

src/playbook/Executables/AtlasModules/Scripts/Modules/Miscellaneous/Miscellaneous.psm1

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,4 @@ function Reset-PerformanceCounters {
3030
winmgmt /resyncperf
3131
}
3232

33-
function Invoke-AllMiscSystemUtilities {
34-
Write-Host "Add-MusicVideosToHome"
35-
Add-MusicVideosToHome
36-
Write-Host "set time servers"
37-
Set-TimeServers
38-
Write-Host "Resetting performance counter"
39-
Reset-PerformanceCounters
40-
}
41-
42-
Export-ModuleMember -Function Invoke-AllMiscSystemUtilities
33+
Export-ModuleMember -Function @()

src/playbook/Executables/AtlasModules/Scripts/Modules/Performance/Performance.psm1

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,4 @@ function Disable-SleepStudy {
5353
schtasks /Change /TN "\Microsoft\Windows\Power Efficiency Diagnostics\AnalyzeSystem" /Disable
5454
}
5555

56-
# Executes all optimizations in sequence
57-
function Invoke-AllPerformanceOptimizations {
58-
Write-Host "Optimizing NTFS"
59-
Optimize-NTFS
60-
Write-Host "disabling auto folder discovery"
61-
Disable-AutoFolderDiscovery
62-
Write-Host "disabling background apps"
63-
Disable-BackgroundApps
64-
Write-Host "disabling game bar"
65-
Disable-GameBar
66-
Write-Host "disabling sleep study"
67-
Disable-SleepStudy
68-
}
69-
70-
Export-ModuleMember -Function Invoke-AllPerformanceOptimizations
56+
Export-ModuleMember -Function @()

src/playbook/Executables/AtlasModules/Scripts/Modules/Privacy/Privacy.psm1

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -111,26 +111,4 @@ function Disable-UserActivityUpload {
111111
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\System" /v "UploadUserActivities" /t REG_DWORD /d 0 /f
112112
}
113113

114-
# Executes all privacy-related optimizations
115-
function Invoke-AllPrivacyOptimizations {
116-
Write-Host "Running privacy optimizations"
117-
Disable-AdvertisingID
118-
Disable-SyncProviderNotifications
119-
Disable-NvidiaTelemetry
120-
Disable-OfficeTelemetry
121-
Disable-DeviceSetupSuggestions
122-
Disable-NETCLITelemetry
123-
Disable-InputTelemetry
124-
Set-WindowsMediaPlayer
125-
Disable-AppLaunchTracking
126-
Disable-OnlineSpeechRecognition
127-
Disable-UserActivityUpload
128-
Set-SearchPrivacy
129-
Disable-RecallSnapshots
130-
Disable-TailoredExperiences
131-
Disable-FrequentApps
132-
Disable-LanguageListAccess
133-
Disable-ErrorReporting
134-
}
135-
136-
Export-ModuleMember -Function Invoke-AllPrivacyOptimizations
114+
Export-ModuleMember -Function @()

src/playbook/Executables/AtlasModules/Scripts/Modules/Qol/Qol.psm1

Lines changed: 1 addition & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -450,71 +450,4 @@ function Set-VisualEffects {
450450
reg add "HKCU\SOFTWARE\Microsoft\Windows\DWM" /v "AlwaysHibernateThumbnails" /t REG_DWORD /d 0 /f
451451
}
452452

453-
function Invoke-AllQolOptimizations {
454-
Write-Host "Running QOL optimizations"
455-
Set-AtlasTheme
456-
Set-TooltipColorBlue
457-
Disable-ThemeChangesToPersonalizedFeatures
458-
Disable-ReadAndScan
459-
Disable-AnnoyingFeaturesAndShortcuts
460-
Disable-AccessibilityToolShortcut
461-
Disable-EaseOfAccessSounds
462-
Remove-ExtractFromContextMenu
463-
Remove-PrintingFromContextMenus
464-
Show-MoreDetailsOnTransfers
465-
Set-SendToContextMenu
466-
Disable-UseCheckBoxesToSelectItems
467-
Hide-GalleryInFileExplorer
468-
Disable-SearchingForInvalidShortcuts
469-
Disable-NetworkNavigationPaneInExplorer
470-
Hide-OfficeFilesInQuickAccess
471-
Show-FullContextMenuOnItems
472-
Hide-RecentItems
473-
Set-MouseHoverTimeForItemInfo
474-
Set-FileExplorerToThisPC
475-
Remove-PreviousVersionsFromExplorer
476-
Remove-ShortcutText
477-
Show-AllFilesWithExtensions
478-
Enable-CompactMode
479-
Disable-ShowEdgeTabsInAltTab
480-
Disable-AutoRun
481-
Disable-AeroShake
482-
Disable-LowDiskSpaceChecks
483-
Disable-MenuHoverDelay
484-
Disable-SharedExperiences
485-
Disable-StartMenuRecommendations
486-
Restore-OldContextMenu
487-
Set-UnpinnedControlCenterItems
488-
Show-MorePinsInStartMenu
489-
Set-ShutdownTime
490-
Disable-StartupDelay
491-
Set-CloseApplicationsOnSessionEnd
492-
Show-CommandPromptOnWinX
493-
Disable-MicrosoftCopilot
494-
Disable-ShowDesktopPeek
495-
Hide-TabletMode
496-
Disable-WindowsChat
497-
Add-EndTaskToTaskbar
498-
Disable-TaskViewOnTaskbar
499-
Set-TaskbarAlignLeft
500-
Add-NetworkSharingShortcut
501-
Set-BootConfiguration
502-
Disable-WallpaperCompression
503-
Set-StartMenu
504-
Set-WindowsInkWorkspace
505-
Disable-AutomaticStoreAppArchiving
506-
Disable-DynamicLighting
507-
Disable-MouseAcceleration
508-
Disable-ScreenCaptureHotkey
509-
Disable-SpellChecking
510-
Disable-UnnecessaryTouchKeyboardSettings
511-
Disable-TouchVisualFeedback
512-
Disable-WindowsFeedback
513-
Disable-WindowsSpotlight
514-
Disable-ReduceSoundsWhileInCall
515-
Hide-DisabledAndDisconnectedDevicesInSoundsPanel
516-
Set-VisualEffects
517-
}
518-
519-
# Export functions for module
520-
Export-ModuleMember -Function Invoke-AllQolOptimizations
453+
Export-ModuleMember -Function @()

src/playbook/Executables/AtlasModules/Scripts/Modules/Scripts/Scripts.psm1

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,41 @@
22
# PowerShell Module for Executing System Scripts
33
# ==============================
44

5+
Set-StrictMode -Version 3.0
6+
57
# Backup Atlas Services and Drivers
68
$windir = $([Environment]::GetFolderPath('Windows'))
79
function Backup-AtlasServices {
810
$filePath = "$([Environment]::GetFolderPath('Windows'))\AtlasModules\Other\atlasServices.reg"
9-
if (Test-Path $FilePath) { exit }
11+
if (Test-Path $FilePath) { return }
1012

1113
$content = [System.Collections.Generic.List[string]]::new()
1214
$content.Add("Windows Registry Editor Version 5.00")
13-
Get-ChildItem "HKLM:\SYSTEM\CurrentControlSet\Services" | ForEach-Object {
14-
try {
15-
$values = Get-ItemProperty -Path $_.PSPath -Name 'Start', 'Description' -EA Stop
16-
if ($values.Description -notmatch 'Windows Defender') {
17-
$content.Add("`n[$($_.Name)]")
18-
$content.Add('"Start"=dword:0000000' + $values.Start)
19-
} else {
20-
Write-Output "Excluding $($_.Name)..."
21-
}
22-
} catch {}
15+
foreach ($serviceKey in (Get-ChildItem "HKLM:\SYSTEM\CurrentControlSet\Services")) {
16+
$serviceProps = Get-ItemProperty -Path $serviceKey.PSPath -ErrorAction SilentlyContinue
17+
if ($null -eq $serviceProps) {
18+
continue
19+
}
20+
21+
$startProperty = $serviceProps.PSObject.Properties['Start']
22+
if ($null -eq $startProperty) {
23+
continue
24+
}
25+
$startValue = $startProperty.Value
26+
27+
$description = $null
28+
$descriptionProperty = $serviceProps.PSObject.Properties['Description']
29+
if ($null -ne $descriptionProperty) {
30+
$description = [string]$descriptionProperty.Value
31+
}
32+
33+
if (($null -ne $description) -and ($description -match 'Windows Defender')) {
34+
Write-Output "Excluding $($serviceKey.Name)..."
35+
continue
36+
}
37+
38+
$content.Add("`n[$($serviceKey.Name)]")
39+
$content.Add('"Start"=dword:0000000' + $startValue)
2340
}
2441

2542
# Set-Content can only do UTF8 with BOM, which doesn't work with reg.exe
@@ -40,10 +57,10 @@ function Update-ClientCBS {
4057
$windir = [Environment]::GetFolderPath('Windows')
4158
$settingsExtensions = (Get-ChildItem "$windir\SystemApps" -Recurse).FullName | Where-Object { $_ -like '*wsxpacks\Account\SettingsExtensions.json*' }
4259
$arm = ((Get-CimInstance -Class Win32_ComputerSystem).SystemType -match 'ARM64') -or ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64')
43-
if ($settingsExtensions.Count -eq 0) {
60+
if (($null -eq $settingsExtensions) -or ($settingsExtensions.Count -eq 0)) {
4461
Write-Output "Settings extensions ($settingsExtensions) not found."
4562
Write-Output "User is likely on Windows 10, nothing to do. Exiting..."
46-
exit
63+
return
4764
}
4865

4966
# Finds velocity IDs listed in 'Accounts' wsxpack
@@ -72,9 +89,9 @@ foreach ($settingsJson in $settingsExtensions) {
7289
}
7390

7491
# No IDs check
75-
if ($ids.Count -le 0) {
92+
if (($null -eq $ids) -or ($ids.Count -le 0)) {
7693
Write-Output "No velocity IDs were found. Exiting."
77-
exit 1
94+
throw "No velocity IDs were found."
7895
}
7996

8097
# Hide 'Microsoft account' page in Settings that appears
@@ -176,7 +193,7 @@ function Disable-Mitigations {
176193
function Optimize-PowerShellStartup {
177194
# speeds up powershell startup time by 10x
178195
$env:path = "$([Runtime.InteropServices.RuntimeEnvironment]::GetRuntimeDirectory());" + $env:path
179-
[AppDomain]::CurrentDomain.GetAssemblies().Location | ? {$_} | % {
196+
[AppDomain]::CurrentDomain.GetAssemblies().Location | Where-Object { $_ } | ForEach-Object {
180197
Write-Host "NGENing: $(Split-Path $_ -Leaf)" -ForegroundColor Yellow
181198
ngen install $_ | Out-Null
182199
}
@@ -242,4 +259,4 @@ function Invoke-AllSystemScripts {
242259
Set-PowerSettings -DisablePowerSaving -DisableHibernation
243260
}
244261

245-
Export-ModuleMember -Function Invoke-AllSystemScripts
262+
Export-ModuleMember -Function Invoke-AllSystemScripts

src/playbook/Executables/AtlasModules/Scripts/Modules/Themes/Themes.psm1

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
Set-StrictMode -Version 3.0
2+
13
$windir = [Environment]::GetFolderPath('Windows')
24

35
function Stop-ThemeProcesses {
@@ -11,7 +13,8 @@ function Set-Theme {
1113
[string]$Path
1214
)
1315

14-
if (!((Get-Item $Path -EA 0).Extension -eq '.theme')) {
16+
$themeItem = Get-Item -Path $Path -ErrorAction SilentlyContinue
17+
if (($null -eq $themeItem) -or ($themeItem.Extension -ne '.theme')) {
1518
throw "'$Path' is not a valid path to a theme file."
1619
}
1720

@@ -111,7 +114,7 @@ function Set-LockscreenImage {
111114
[Windows.System.UserProfile.LockScreen, Windows.System.UserProfile, ContentType = WindowsRuntime] | Out-Null
112115

113116
# setup async
114-
$asTaskGeneric = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? {
117+
$asTaskGeneric = ([System.WindowsRuntimeSystemExtensions].GetMethods() | Where-Object {
115118
$_.Name -eq 'AsTask' -and
116119
$_.GetParameters().Count -eq 1 -and
117120
$_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1'
@@ -123,7 +126,7 @@ function Set-LockscreenImage {
123126
$netTask.Result
124127
}
125128
Function AwaitAction($WinRtAction) {
126-
$asTask = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and !$_.IsGenericMethod })[0]
129+
$asTask = ([System.WindowsRuntimeSystemExtensions].GetMethods() | Where-Object { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and !$_.IsGenericMethod })[0]
127130
$netTask = $asTask.Invoke($null, @($WinRtAction))
128131
$netTask.Wait(-1) | Out-Null
129132
}
@@ -139,4 +142,4 @@ function Set-LockscreenImage {
139142
Remove-Item $newImagePath
140143
}
141144

142-
Export-ModuleMember -Function Set-Theme, Set-ThemeMRU, Set-LockscreenImage
145+
Export-ModuleMember -Function Set-Theme, Set-ThemeMRU, Set-LockscreenImage

0 commit comments

Comments
 (0)