Skip to content

Scripts

Some of the scripts I use

Add Desktop Icons

Script
Terminal window
#======================================================================================
# Load Registry Hives
#======================================================================================
$RegDefault = "$MountDirectory\Windows\System32\Config\Default"
if (Test-Path $RegDefault) {
Write-Host "Loading $RegDefault" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountDefault $RegDefault" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
$RegDefaultUser = "$MountDirectory\Users\Default\ntuser.dat"
if (Test-Path $RegDefaultUser) {
Write-Host "Loading $RegDefaultUser" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountDefaultUser $RegDefaultUser" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
$RegSoftware = "$MountDirectory\Windows\System32\Config\Software"
if (Test-Path $RegSoftware) {
Write-Host "Loading $RegSoftware" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountSoftware $RegSoftware" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
$RegSystem = "$MountDirectory\Windows\System32\Config\System"
if (Test-Path $RegSystem) {
Write-Host "Loading $RegSystem" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountSystem $RegSystem" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
#======================================================================================
# Registry Commands
#======================================================================================
# Tested and Working
$RegCommands =
# Hide OneDrive
'add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" /v {018D5C66-4533-4307-9B53-224DE2ED1FE6} /t REG_DWORD /d 1 /f',
# Hide User Folder
'add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" /v {59031a47-3f72-44a7-89c5-5595fe6b30ee} /t REG_DWORD /d 1 /f',
# Hide Network and Sharing
'add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" /v {F02C1A0D-BE21-4350-88B0-7367FC96EF3C} /t REG_DWORD /d 1 /f',
# Show My Computer
'add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" /v {20D04FE0-3AEA-1069-A2D8-08002B30309D} /t REG_DWORD /d 0 /f',
# Show Control Panel
'add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" /v {5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0} /t REG_DWORD /d 0 /f',
# Show Recycle Bin
'add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" /v {645FF040-5081-101B-9F08-00AA002F954E} /t REG_DWORD /d 0 /f'
#======================================================================================
# Process Registry Commands
#======================================================================================
foreach ($Command in $RegCommands) {
if ($Command -like "*HKCU*") {
$Command = $Command -replace "HKCU","HKLM\MountDefaultUser"
Write-Host "reg $Command" -ForegroundColor DarkGray
Start-Process reg -ArgumentList $Command -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
} elseif ($Command -like "*HKLM\Software*") {
$Command = $Command -replace "HKLM\\Software","HKLM\MountSoftware"
Write-Host "reg $Command" -ForegroundColor DarkGray
Start-Process reg -ArgumentList $Command -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
} elseif ($Command -like "*HKLM\System*") {
$Command = $Command -replace "HKLM\\System","HKLM\MountSystem"
Write-Host "reg $Command" -ForegroundColor DarkGray
Start-Process reg -ArgumentList $Command -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
}
#======================================================================================
# Unload Registry Hives
#======================================================================================
Start-Process reg -ArgumentList "unload HKLM\MountDefault" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
Start-Process reg -ArgumentList "unload HKLM\MountDefaultUser" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
Start-Process reg -ArgumentList "unload HKLM\MountSoftware" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
Start-Process reg -ArgumentList "unload HKLM\MountSystem" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
#======================================================================================
# Testing
#======================================================================================
# [void](Read-Host 'Press Enter to continue')

Customize Explorer

Script
Terminal window
#======================================================================================
# Load Registry Hives
#======================================================================================
$RegDefault = "$MountDirectory\Windows\System32\Config\Default"
if (Test-Path $RegDefault) {
Write-Host "Loading $RegDefault" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountDefault $RegDefault" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
$RegDefaultUser = "$MountDirectory\Users\Default\ntuser.dat"
if (Test-Path $RegDefaultUser) {
Write-Host "Loading $RegDefaultUser" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountDefaultUser $RegDefaultUser" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
$RegSoftware = "$MountDirectory\Windows\System32\Config\Software"
if (Test-Path $RegSoftware) {
Write-Host "Loading $RegSoftware" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountSoftware $RegSoftware" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
$RegSystem = "$MountDirectory\Windows\System32\Config\System"
if (Test-Path $RegSystem) {
Write-Host "Loading $RegSystem" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountSystem $RegSystem" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
#======================================================================================
# Registry Commands
#======================================================================================
# Tested and Working
$RegCommands =
# https://admx.help/?Category=Windows_11_2022&Policy=Microsoft.Policies.WindowsExplorer::ConfirmFileDelete
# Display confirmation dialog when deleting files
'add "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v ConfirmFileDelete /t REG_DWORD /d 1 /f',
# Show File Extensions
'add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v HideFileExt /t REG_DWORD /d 0 /f',
# Start File Explorer to This PC
'add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v LaunchTo /t REG_DWORD /d 1 /f'
#======================================================================================
# Process Registry Commands
#======================================================================================
foreach ($Command in $RegCommands) {
if ($Command -like "*HKCU*") {
$Command = $Command -replace "HKCU","HKLM\MountDefaultUser"
Write-Host "reg $Command" -ForegroundColor DarkGray
Start-Process reg -ArgumentList $Command -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
} elseif ($Command -like "*HKLM\Software*") {
$Command = $Command -replace "HKLM\\Software","HKLM\MountSoftware"
Write-Host "reg $Command" -ForegroundColor DarkGray
Start-Process reg -ArgumentList $Command -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
} elseif ($Command -like "*HKLM\System*") {
$Command = $Command -replace "HKLM\\System","HKLM\MountSystem"
Write-Host "reg $Command" -ForegroundColor DarkGray
Start-Process reg -ArgumentList $Command -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
}
#======================================================================================
# Unload Registry Hives
#======================================================================================
Start-Process reg -ArgumentList "unload HKLM\MountDefault" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
Start-Process reg -ArgumentList "unload HKLM\MountDefaultUser" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
Start-Process reg -ArgumentList "unload HKLM\MountSoftware" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
Start-Process reg -ArgumentList "unload HKLM\MountSystem" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
#======================================================================================
# Testing
#======================================================================================
# [void](Read-Host 'Press Enter to continue')

Customize TaskBar

Script
Terminal window
#======================================================================================
# Load Registry Hives
#======================================================================================
$RegDefault = "$MountDirectory\Windows\System32\Config\Default"
if (Test-Path $RegDefault) {
Write-Host "Loading $RegDefault" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountDefault $RegDefault" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
$RegDefaultUser = "$MountDirectory\Users\Default\ntuser.dat"
if (Test-Path $RegDefaultUser) {
Write-Host "Loading $RegDefaultUser" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountDefaultUser $RegDefaultUser" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
$RegSoftware = "$MountDirectory\Windows\System32\Config\Software"
if (Test-Path $RegSoftware) {
Write-Host "Loading $RegSoftware" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountSoftware $RegSoftware" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
$RegSystem = "$MountDirectory\Windows\System32\Config\System"
if (Test-Path $RegSystem) {
Write-Host "Loading $RegSystem" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountSystem $RegSystem" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
#======================================================================================
# Registry Commands
#======================================================================================
# Tested and Working
$RegCommands =
# Align TaskBar to Left
'add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v TaskbarAl /t REG_DWORD /d 0 /f',
# Remove Widget Icon
'add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v TaskbarDa /t REG_DWORD /d 0 /f',
# Remove Chat Icon
'add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v TaskbarMn /t REG_DWORD /d 0 /f',
# Remove Task View Icon
'add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v ShowTaskViewButton /t REG_DWORD /d 0 /f',
# https://admx.help/?Category=Windows_11_2022&Policy=Microsoft.Policies.StartMenu::ClearRecentProgForNewUserInStartMenu
# Clear the recent programs list for new users
'add "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v ClearRecentProgForNewUserInStartMenu /t REG_DWORD /d 1 /f',
# https://admx.help/?Category=Windows_11_2022&Policy=Microsoft.Policies.StartMenu::NoSearchInternetInStartMenu
# Do not search Internet history
'add "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v NoSearchInternetInStartMenu /t REG_DWORD /d 1 /f',
# https://admx.help/?Category=Windows_11_2022&Policy=Microsoft.Policies.WindowsExplorer::DisableSearchBoxSuggestions
# Do not suggest results
'add "HKCU\Software\Policies\Microsoft\Windows\Explorer" /v DisableSearchBoxSuggestions /t REG_DWORD /d 1 /f',
# https://admx.help/?Category=Windows_11_2022&Policy=Microsoft.Policies.TaskBar2::NoPinningStoreToTaskbar
# Do not pin MS Store to task bar
'add "HKCU\Software\Policies\Microsoft\Windows\Explorer" /v NoPinningStoreToTaskbar /t REG_DWORD /d 1 /f'
#======================================================================================
# Process Registry Commands
#======================================================================================
foreach ($Command in $RegCommands) {
if ($Command -like "*HKCU*") {
$Command = $Command -replace "HKCU","HKLM\MountDefaultUser"
Write-Host "reg $Command" -ForegroundColor DarkGray
Start-Process reg -ArgumentList $Command -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
} elseif ($Command -like "*HKLM\Software*") {
$Command = $Command -replace "HKLM\\Software","HKLM\MountSoftware"
Write-Host "reg $Command" -ForegroundColor DarkGray
Start-Process reg -ArgumentList $Command -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
} elseif ($Command -like "*HKLM\System*") {
$Command = $Command -replace "HKLM\\System","HKLM\MountSystem"
Write-Host "reg $Command" -ForegroundColor DarkGray
Start-Process reg -ArgumentList $Command -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
}
#======================================================================================
# Unload Registry Hives
#======================================================================================
Start-Process reg -ArgumentList "unload HKLM\MountDefault" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
Start-Process reg -ArgumentList "unload HKLM\MountDefaultUser" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
Start-Process reg -ArgumentList "unload HKLM\MountSoftware" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
Start-Process reg -ArgumentList "unload HKLM\MountSystem" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
#======================================================================================
# Testing
#======================================================================================
# [void](Read-Host 'Press Enter to continue')

Disable Cortana

Script
Terminal window
#======================================================================================
# Load Registry Hives
#======================================================================================
$RegDefault = "$MountDirectory\Windows\System32\Config\Default"
if (Test-Path $RegDefault) {
Write-Host "Loading $RegDefault" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountDefault $RegDefault" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
$RegDefaultUser = "$MountDirectory\Users\Default\ntuser.dat"
if (Test-Path $RegDefaultUser) {
Write-Host "Loading $RegDefaultUser" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountDefaultUser $RegDefaultUser" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
$RegSoftware = "$MountDirectory\Windows\System32\Config\Software"
if (Test-Path $RegSoftware) {
Write-Host "Loading $RegSoftware" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountSoftware $RegSoftware" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
$RegSystem = "$MountDirectory\Windows\System32\Config\System"
if (Test-Path $RegSystem) {
Write-Host "Loading $RegSystem" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountSystem $RegSystem" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
#======================================================================================
# Registry Commands
#======================================================================================
# Tested and Working
$RegCommands =
# https://admx.help/?Category=Windows_11_2022&Policy=FullArmor.Policies.3B9EA2B5_A1D1_4CD5_9EDE_75B22990BC21::AllowCortana
# Disable Cortana
'add "HKLM\SOFTWARE\Policies\Microsoft\Windows\Windows Search" /v AllowCortana /t REG_DWORD /d 0 /f'
#======================================================================================
# Process Registry Commands
#======================================================================================
foreach ($Command in $RegCommands) {
if ($Command -like "*HKCU*") {
$Command = $Command -replace "HKCU","HKLM\MountDefaultUser"
Write-Host "reg $Command" -ForegroundColor DarkGray
Start-Process reg -ArgumentList $Command -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
} elseif ($Command -like "*HKLM\Software*") {
$Command = $Command -replace "HKLM\\Software","HKLM\MountSoftware"
Write-Host "reg $Command" -ForegroundColor DarkGray
Start-Process reg -ArgumentList $Command -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
} elseif ($Command -like "*HKLM\System*") {
$Command = $Command -replace "HKLM\\System","HKLM\MountSystem"
Write-Host "reg $Command" -ForegroundColor DarkGray
Start-Process reg -ArgumentList $Command -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
}
#======================================================================================
# Unload Registry Hives
#======================================================================================
Start-Process reg -ArgumentList "unload HKLM\MountDefault" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
Start-Process reg -ArgumentList "unload HKLM\MountDefaultUser" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
Start-Process reg -ArgumentList "unload HKLM\MountSoftware" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
Start-Process reg -ArgumentList "unload HKLM\MountSystem" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
#======================================================================================
# Testing
#======================================================================================
# [void](Read-Host 'Press Enter to continue')

Disable Notifications

Script
Terminal window
#======================================================================================
# Load Registry Hives
#======================================================================================
$RegDefault = "$MountDirectory\Windows\System32\Config\Default"
if (Test-Path $RegDefault) {
Write-Host "Loading $RegDefault" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountDefault $RegDefault" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
$RegDefaultUser = "$MountDirectory\Users\Default\ntuser.dat"
if (Test-Path $RegDefaultUser) {
Write-Host "Loading $RegDefaultUser" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountDefaultUser $RegDefaultUser" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
$RegSoftware = "$MountDirectory\Windows\System32\Config\Software"
if (Test-Path $RegSoftware) {
Write-Host "Loading $RegSoftware" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountSoftware $RegSoftware" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
$RegSystem = "$MountDirectory\Windows\System32\Config\System"
if (Test-Path $RegSystem) {
Write-Host "Loading $RegSystem" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountSystem $RegSystem" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
#======================================================================================
# Registry Commands
#======================================================================================
# Tested and working
$RegCommands =
# https://admx.help/?Category=Windows_11_2022&Policy=Microsoft.Policies.TaskBar2::TaskbarNoNotification
# Turn off all balloon notifications
'add "HKCU\Software\Policies\Microsoft\Windows\Explorer" /v TaskbarNoNotification /t REG_DWORD /d 1 /f',
# https://admx.help/?Category=Windows_11_2022&Policy=Microsoft.Policies.TaskBar2::NoSystraySystemPromotion
# Turn off automatic promotion of notification icons to the taskbar
'add "HKCU\Software\Policies\Microsoft\Windows\Explorer" /v NoSystraySystemPromotion /t REG_DWORD /d 1 /f',
# https://admx.help/?Category=Windows_11_2022&Policy=Microsoft.Policies.TaskBar2::NoBalloonFeatureAdvertisements
# Turn off feature advertisement balloon notifications
'add "HKCU\Software\Policies\Microsoft\Windows\Explorer" /v NoBalloonFeatureAdvertisements /t REG_DWORD /d 1 /f',
# https://admx.help/?Category=Windows_11_2022&Policy=Microsoft.Policies.Notifications::NoLockScreenToastNotification
# Turn off toast notifications on the lock screen
'add "HKCU\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications" /v NoToastApplicationNotificationOnLockScreen /t REG_DWORD /d 1 /f',
# https://admx.help/?Category=Windows_11_2022&Policy=Microsoft.Policies.Notifications::NoToastNotification
# Turn off toast notifications
'add "HKCU\Software\Policies\Microsoft\Windows\CurrentVersion\PushNotifications" /v NoToastApplicationNotification /t REG_DWORD /d 1 /f',
# https://admx.help/?Category=Windows_11_2022&Policy=Microsoft.Policies.Notifications::NoToastNotification
# Turn off toast notifications for MS Store
'add "HKCU\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Microsoft.WindowsStore_8wekyb3d8bbwe!App" /v Enabled /t REG_DWORD /d 0 /f'
#======================================================================================
# Process Registry Commands
#======================================================================================
foreach ($Command in $RegCommands) {
if ($Command -like "*HKCU*") {
$Command = $Command -replace "HKCU","HKLM\MountDefaultUser"
Write-Host "reg $Command" -ForegroundColor DarkGray
Start-Process reg -ArgumentList $Command -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
} elseif ($Command -like "*HKLM\Software*") {
$Command = $Command -replace "HKLM\\Software","HKLM\MountSoftware"
Write-Host "reg $Command" -ForegroundColor DarkGray
Start-Process reg -ArgumentList $Command -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
} elseif ($Command -like "*HKLM\System*") {
$Command = $Command -replace "HKLM\\System","HKLM\MountSystem"
Write-Host "reg $Command" -ForegroundColor DarkGray
Start-Process reg -ArgumentList $Command -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
}
#======================================================================================
# Unload Registry Hives
#======================================================================================
Start-Process reg -ArgumentList "unload HKLM\MountDefault" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
Start-Process reg -ArgumentList "unload HKLM\MountDefaultUser" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
Start-Process reg -ArgumentList "unload HKLM\MountSoftware" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
Start-Process reg -ArgumentList "unload HKLM\MountSystem" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
#======================================================================================
# Testing
#======================================================================================
# [void](Read-Host 'Press Enter to continue')

Disable Personalization Menus

Script
Terminal window
#======================================================================================
# Load Registry Hives
#======================================================================================
$RegDefault = "$MountDirectory\Windows\System32\Config\Default"
if (Test-Path $RegDefault) {
Write-Host "Loading $RegDefault" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountDefault $RegDefault" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
$RegDefaultUser = "$MountDirectory\Users\Default\ntuser.dat"
if (Test-Path $RegDefaultUser) {
Write-Host "Loading $RegDefaultUser" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountDefaultUser $RegDefaultUser" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
$RegSoftware = "$MountDirectory\Windows\System32\Config\Software"
if (Test-Path $RegSoftware) {
Write-Host "Loading $RegSoftware" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountSoftware $RegSoftware" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
$RegSystem = "$MountDirectory\Windows\System32\Config\System"
if (Test-Path $RegSystem) {
Write-Host "Loading $RegSystem" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountSystem $RegSystem" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
#======================================================================================
# Registry Commands
#======================================================================================
# Tested and working
$RegCommands =
# https://admx.help/?Category=Windows_11_2022&Policy=Microsoft.Policies.StartMenu::Intellimenus
# Turn off personalized menus
'add "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v Intellimenus /t REG_DWORD /d 1 /f',
# https://admx.help/?Category=Windows_11_2022&Policy=Microsoft.Policies.StartMenu::NoInstrumentation
# Turn off user tracking
'add "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v NoInstrumentation /t REG_DWORD /d 0 /f'
#======================================================================================
# Process Registry Commands
#======================================================================================
foreach ($Command in $RegCommands) {
if ($Command -like "*HKCU*") {
$Command = $Command -replace "HKCU","HKLM\MountDefaultUser"
Write-Host "reg $Command" -ForegroundColor DarkGray
Start-Process reg -ArgumentList $Command -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
} elseif ($Command -like "*HKLM\Software*") {
$Command = $Command -replace "HKLM\\Software","HKLM\MountSoftware"
Write-Host "reg $Command" -ForegroundColor DarkGray
Start-Process reg -ArgumentList $Command -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
} elseif ($Command -like "*HKLM\System*") {
$Command = $Command -replace "HKLM\\System","HKLM\MountSystem"
Write-Host "reg $Command" -ForegroundColor DarkGray
Start-Process reg -ArgumentList $Command -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
}
#======================================================================================
# Unload Registry Hives
#======================================================================================
Start-Process reg -ArgumentList "unload HKLM\MountDefault" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
Start-Process reg -ArgumentList "unload HKLM\MountDefaultUser" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
Start-Process reg -ArgumentList "unload HKLM\MountSoftware" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
Start-Process reg -ArgumentList "unload HKLM\MountSystem" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
#======================================================================================
# Testing
#======================================================================================
# [void](Read-Host 'Press Enter to continue')

Remove OneDrive Setup

Script
Terminal window
# David Segura
# http://osdeploy.com
#
# OSBuilder Script
# Windows 10 Remove-OneDriveSetup.ps1
# Version 19.1.18
#======================================================================================
# Remove Files
#======================================================================================
if (Test-Path "$MountDirectory\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk") {
Remove-Item -Path "$MountDirectory\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk" -Force | Out-Null
}
#======================================================================================
# Load Registry Hives
#======================================================================================
$RegDefault = "$MountDirectory\Windows\System32\Config\Default"
if (Test-Path $RegDefault) {
Write-Host "Loading $RegDefault" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountDefault $RegDefault" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
$RegDefaultUser = "$MountDirectory\Users\Default\ntuser.dat"
if (Test-Path $RegDefaultUser) {
Write-Host "Loading $RegDefaultUser" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountDefaultUser $RegDefaultUser" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
$RegSoftware = "$MountDirectory\Windows\System32\Config\Software"
if (Test-Path $RegSoftware) {
Write-Host "Loading $RegSoftware" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountSoftware $RegSoftware" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
$RegSystem = "$MountDirectory\Windows\System32\Config\System"
if (Test-Path $RegSystem) {
Write-Host "Loading $RegSystem" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountSystem $RegSystem" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
#======================================================================================
# Registry Commands
#======================================================================================
# Tested and Working
$RegCommands =
'delete HKCU\Software\Microsoft\Windows\CurrentVersion\Run /v OneDriveSetup /f'
#======================================================================================
# Process Registry Commands
#======================================================================================
foreach ($Command in $RegCommands) {
if ($Command -like "*HKCU*") {
$Command = $Command -replace "HKCU","HKLM\MountDefaultUser"
Write-Host "reg $Command" -ForegroundColor DarkGray
Start-Process reg -ArgumentList $Command -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
} elseif ($Command -like "*HKLM\Software*") {
$Command = $Command -replace "HKLM\\Software","HKLM\MountSoftware"
Write-Host "reg $Command" -ForegroundColor DarkGray
Start-Process reg -ArgumentList $Command -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
} elseif ($Command -like "*HKLM\System*") {
$Command = $Command -replace "HKLM\\System","HKLM\MountSystem"
Write-Host "reg $Command" -ForegroundColor DarkGray
Start-Process reg -ArgumentList $Command -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
}
#======================================================================================
# Unload Registry Hives
#======================================================================================
Start-Process reg -ArgumentList "unload HKLM\MountDefault" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
Start-Process reg -ArgumentList "unload HKLM\MountDefaultUser" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
Start-Process reg -ArgumentList "unload HKLM\MountSoftware" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
Start-Process reg -ArgumentList "unload HKLM\MountSystem" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
#======================================================================================
# Testing
#======================================================================================
# [void](Read-Host 'Press Enter to continue')

Power Profile Customizations

Script
Terminal window
#======================================================================================
# Load Registry Hives
#======================================================================================
$RegDefault = "$MountDirectory\Windows\System32\Config\Default"
if (Test-Path $RegDefault) {
Write-Host "Loading $RegDefault" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountDefault $RegDefault" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
$RegDefaultUser = "$MountDirectory\Users\Default\ntuser.dat"
if (Test-Path $RegDefaultUser) {
Write-Host "Loading $RegDefaultUser" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountDefaultUser $RegDefaultUser" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
$RegSoftware = "$MountDirectory\Windows\System32\Config\Software"
if (Test-Path $RegSoftware) {
Write-Host "Loading $RegSoftware" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountSoftware $RegSoftware" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
$RegSystem = "$MountDirectory\Windows\System32\Config\System"
if (Test-Path $RegSystem) {
Write-Host "Loading $RegSystem" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountSystem $RegSystem" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
#======================================================================================
# Registry Commands
#======================================================================================
# Tested and Working
# Info for all reg keys: https://docs.microsoft.com/en-us/windows-hardware/customize/power-settings/configure-power-settings
$RegCommands =
# https://docs.microsoft.com/en-us/windows/win32/power/power-policy-settings
# Select an active power plan (Performance)
'add "HKLM\SOFTWARE\Policies\Microsoft\Power\PowerSettings" /v ActivePowerScheme /t REG_SZ /d 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c /f',
# https://admx.help/?Category=Windows_11_2022&Policy=Microsoft.Policies.PowerManagement::VideoPowerDownTimeOutDC_2 - VIDEOIDLE
# Never turn off display on Battery
'add "HKLM\SOFTWARE\Policies\Microsoft\Power\PowerSettings\3c0bc021-c8a8-4e07-a973-6b14cbcb2b7e" /v DCSettingIndex /t REG_DWORD /d 0 /f',
# https://admx.help/?Category=Windows_11_2022&Policy=Microsoft.Policies.PowerManagement::VideoPowerDownTimeOutAC_2 - VIDEOIDLE
# Never turn off display on AC
'add "HKLM\SOFTWARE\Policies\Microsoft\Power\PowerSettings\3c0bc021-c8a8-4e07-a973-6b14cbcb2b7e" /v ACSettingIndex /t REG_DWORD /d 0 /f',
# https://admx.help/?Category=Windows_11_2022&Policy=Microsoft.Policies.PowerManagement::UnattendedSleepTimeOutAC
# Never sleep on AC (Unattended)
'add "HKLM\SOFTWARE\Policies\Microsoft\Power\PowerSettings\7bc4a2f9-d8fc-4469-b07b-33eb785aaca0" /v ACSettingIndex /t REG_DWORD /d 0 /f',
# https://admx.help/?Category=Windows_11_2022&Policy=Microsoft.Policies.PowerManagement::UnattendedSleepTimeOutDC
# Never sleep on Battery (Unattended)
'add "HKLM\SOFTWARE\Policies\Microsoft\Power\PowerSettings\7bc4a2f9-d8fc-4469-b07b-33eb785aaca0" /v DCSettingIndex /t REG_DWORD /d 0 /f',
# https://admx.help/?Category=Windows_11_2022&Policy=Microsoft.Policies.PowerManagement::ACStandbyTimeOut_2 - STANDBYIDLE
# Never sleep on AC (System)
'add "HKLM\SOFTWARE\Policies\Microsoft\Power\PowerSettings\29f6c1db-86da-48c5-9fdb-f2b67b1f44da" /v ACSettingIndex /t REG_DWORD /d 0 /f',
# https://admx.help/?Category=Windows_11_2022&Policy=Microsoft.Policies.PowerManagement::DCStandbyTimeOut_2 - STANDBYIDLE
# Never sleep on Battery (System)
'add "HKLM\SOFTWARE\Policies\Microsoft\Power\PowerSettings\29f6c1db-86da-48c5-9fdb-f2b67b1f44da" /v DCSettingIndex /t REG_DWORD /d 0 /f'
#======================================================================================
# Process Registry Commands
#======================================================================================
foreach ($Command in $RegCommands) {
if ($Command -like "*HKCU*") {
$Command = $Command -replace "HKCU","HKLM\MountDefaultUser"
Write-Host "reg $Command" -ForegroundColor DarkGray
Start-Process reg -ArgumentList $Command -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
} elseif ($Command -like "*HKLM\Software*") {
$Command = $Command -replace "HKLM\\Software","HKLM\MountSoftware"
Write-Host "reg $Command" -ForegroundColor DarkGray
Start-Process reg -ArgumentList $Command -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
} elseif ($Command -like "*HKLM\System*") {
$Command = $Command -replace "HKLM\\System","HKLM\MountSystem"
Write-Host "reg $Command" -ForegroundColor DarkGray
Start-Process reg -ArgumentList $Command -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
}
#======================================================================================
# Unload Registry Hives
#======================================================================================
Start-Process reg -ArgumentList "unload HKLM\MountDefault" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
Start-Process reg -ArgumentList "unload HKLM\MountDefaultUser" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
Start-Process reg -ArgumentList "unload HKLM\MountSoftware" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
Start-Process reg -ArgumentList "unload HKLM\MountSystem" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
#======================================================================================
# Testing
#======================================================================================
# [void](Read-Host 'Press Enter to continue')

Enable Storage Sense

Script
Terminal window
#======================================================================================
# Load Registry Hives
#======================================================================================
$RegDefault = "$MountDirectory\Windows\System32\Config\Default"
if (Test-Path $RegDefault) {
Write-Host "Loading $RegDefault" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountDefault $RegDefault" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
$RegDefaultUser = "$MountDirectory\Users\Default\ntuser.dat"
if (Test-Path $RegDefaultUser) {
Write-Host "Loading $RegDefaultUser" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountDefaultUser $RegDefaultUser" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
$RegSoftware = "$MountDirectory\Windows\System32\Config\Software"
if (Test-Path $RegSoftware) {
Write-Host "Loading $RegSoftware" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountSoftware $RegSoftware" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
$RegSystem = "$MountDirectory\Windows\System32\Config\System"
if (Test-Path $RegSystem) {
Write-Host "Loading $RegSystem" -ForegroundColor DarkGray
Start-Process reg -ArgumentList "load HKLM\MountSystem $RegSystem" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
#======================================================================================
# Registry Commands
#======================================================================================
# Tested and Working
$RegCommands =
# https://admx.help/?Category=Windows_11_2022&Policy=Microsoft.Policies.StorageSense::SS_AllowStorageSenseGlobal
# Enable Storage Sense
'add "HKLM\SOFTWARE\Policies\Microsoft\Windows\StorageSense" /v AllowStorageSenseGlobal /t REG_DWORD /d 1 /f',
# https://admx.help/?Category=Windows_11_2022&Policy=Microsoft.Policies.StorageSense::SS_AllowStorageSenseTemporaryFilesCleanup
# Allow deleting temporary files
'add "HKLM\SOFTWARE\Policies\Microsoft\Windows\StorageSense" /v AllowStorageSenseTemporaryFilesCleanup /t REG_DWORD /d 1 /f',
# https://admx.help/?Category=Windows_11_2022&Policy=Microsoft.Policies.StorageSense::SS_ConfigStorageSenseDownloadsCleanupThreshold
# Do not delete downloads
'add "HKLM\SOFTWARE\Policies\Microsoft\Windows\StorageSense" /v ConfigStorageSenseDownloadsCleanupThreshold /t REG_DWORD /d 0 /f',
# https://admx.help/?Category=Windows_11_2022&Policy=Microsoft.Policies.StorageSense::SS_ConfigStorageSenseRecycleBinCleanupThreshold
# Empty Recycle Bin after 15 Days
'add "HKLM\SOFTWARE\Policies\Microsoft\Windows\StorageSense" /v ConfigStorageSenseRecycleBinCleanupThreshold /t REG_DWORD /d 15 /f',
# https://admx.help/?Category=Windows_11_2022&Policy=Microsoft.Policies.StorageSense::SS_ConfigStorageSenseGlobalCadence
# Run storage sense every day
'add "HKLM\SOFTWARE\Policies\Microsoft\Windows\StorageSense" /v ConfigStorageSenseGlobalCadence /t REG_DWORD /d 1 /f'
#======================================================================================
# Process Registry Commands
#======================================================================================
foreach ($Command in $RegCommands) {
if ($Command -like "*HKCU*") {
$Command = $Command -replace "HKCU","HKLM\MountDefaultUser"
Write-Host "reg $Command" -ForegroundColor DarkGray
Start-Process reg -ArgumentList $Command -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
} elseif ($Command -like "*HKLM\Software*") {
$Command = $Command -replace "HKLM\\Software","HKLM\MountSoftware"
Write-Host "reg $Command" -ForegroundColor DarkGray
Start-Process reg -ArgumentList $Command -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
} elseif ($Command -like "*HKLM\System*") {
$Command = $Command -replace "HKLM\\System","HKLM\MountSystem"
Write-Host "reg $Command" -ForegroundColor DarkGray
Start-Process reg -ArgumentList $Command -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
}
}
#======================================================================================
# Unload Registry Hives
#======================================================================================
Start-Process reg -ArgumentList "unload HKLM\MountDefault" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
Start-Process reg -ArgumentList "unload HKLM\MountDefaultUser" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
Start-Process reg -ArgumentList "unload HKLM\MountSoftware" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
Start-Process reg -ArgumentList "unload HKLM\MountSystem" -Wait -WindowStyle Hidden -ErrorAction SilentlyContinue
#======================================================================================
# Testing
#======================================================================================
# [void](Read-Host 'Press Enter to continue')