#region Third

# Install Chocolatey and O&O Shutup
Function InstallFTTProgs {
	# Check if winget is installed
	if (Test-Path ~\AppData\Local\Microsoft\WindowsApps\winget.exe){
		Write-Output "Winget Already Installed."
	}  
	else{
		# Installing winget from the Microsoft Store
		Write-Output "Winget not found, installing it now."
		Start-Process "ms-appinstaller:?source=https://aka.ms/getwinget"
		$nid = (Get-Process AppInstaller).Id
		Wait-Process -Id $nid
		Write-Output "Winget Installed"    
	}
	
	Write-Output "Running O&O Shutup with Recommended Settings"
	Import-Module BitsTransfer
	Start-BitsTransfer -Source "https://dl5.oo-software.com/files/ooshutup10/OOSU10.exe" -Destination OOSU10.exe
	.\OOSU10.exe ooshutup10.cfg /quiet
}

# Install Adobe Reader
Function InstallAdobe {
	Write-Output "Installing Adobe Acrobat Reader"
	winget install -e Adobe.AdobeAcrobatReaderDC
}

# Do not install Adobe Reader
Function DoNotInstallAdobe {
	Write-Output "Not installing Adobe Acrobat Reader"
}

# Install Java
Function InstallJava {
	Write-Output "Installing Java"
	winget install -e Oracle.JavaRuntimeEnvironment
}

# Do not install Java
Function DoInstallJava {
	Write-Output "Not installing Java"	
}

# Install 7-Zip
Function Install7Zip {
	Write-Output "Installing 7-Zip"
	winget install -e 7zip.7zip
}

# Do not install 7-Zip
Function DoNotInstall7Zip {
	Write-Output "Not installing 7-Zip"
}

# Install Notepad ++
Function InstallNotepadplusplus {
	Write-Output "Installing Notepad++"
	winget install -e Notepad++.Notepad++
}

# Do not install Notepad ++
Function DoNotInstallNotepadplusplus {
	Write-Output "Not installing Notepad++"
}

# Install MPCHC
Function InstallMediaPlayerClassic {
	Write-Output "Installing Media Player Classic (VLC Alternative)"
	winget install -e clsid2.mpc-hc
}

# Do not install MPCHC
Function DoNotInstallMediaPlayerClassic {
	Write-Output "Not installing Media Player Classic (VLC Alternative)"
}

# Install VLC
Function InstallVLCMediaPlayer {
	Write-Output "Installing VLC"
	winget install -e VideoLAN.VLC
}

# Do not install VLC
Function DoNotInstallVLCMediaPlayer {
	Write-Output "Not installing VLC"
}

# Install Brave
Function InstallBrave {
	Write-Output "Installing Brave"
	winget install -e BraveSoftware.BraveBrowser
}

# Do not install Brave
Function DoNotInstallBrave {
	Write-Output "Not installing Brave"
}

# Install Firefox
Function InstallFirefox {	
	Write-Output "Installing Firefox"
	winget install -e Mozilla.Firefox
}

# Do not install Firefox
Function DoNotInstallFirefox {
	Write-Output "Not installing Firefox"
}

# Install Microsoft Terminal
Function InstallTerminal {	
	Write-Output "Installing Microsoft Terminal"
	winget install -e Microsoft.WindowsTerminal
}

# Do not install Microsoft Terminal
Function DoNotInstallTerminal {
	Write-Output "Not installing Microsoft Terminal"
}

# Install Microsoft PowerToys
Function InstallPowertoys {
	Write-Output "Installing Microsoft PowerToys"
	winget install -e Microsoft.PowerToys
}

# Do not install Microsoft PowerToys
Function DoNotInstallPowertoys {
	Write-Output "Not installing Microsoft PowerToys"
}

# Install Google Chrome
Function InstallChrome {
	Write-Output "Installing Google Chrome"
	winget install -e Google.Chrome
}

# Do not install Google Chrome
Function DoNotInstallChrome {
	Write-Output "Not installing Google Chrome"
}

# Install Irfanview
Function InstallIrfanview {
	Write-Output "Installing Irfanview"
	winget install -e IrfanSkiljan.IrfanView
}

# Do not install Irfanview
Function DoNotInstallIrfanview {
	Write-Output "Not installing Irfanview"
}

# Install SumatraPDF
Function InstallSumatrapdf {	
	Write-Output "Installing SumatraPDF"
	winget install -e SumatraPDF.SumatraPDF
}

# Do not install SumatraPDF
Function DoNotInstallSumatrapdf {
	Write-Output "Not installing SumatraPDF"
}


# Install AutoHotkey
Function InstallAutoHotkey {
	Write-Output "Installing AutoHotkey"
	winget install -e Lexikos.AutoHotkey
}

# Do not install AutoHotkey
Function DoNotInstallAutoHotkey {
	Write-Output "Not installing AutoHotkey"
}

# Install ImageGlass
Function InstallImageGlass {
	Write-Output "Installing Image Glass"
	winget install -e DuongDieuPhap.ImageGlass
}

# Do not install ImageGlass
Function DoNotInstallImageGlass {
	Write-Output "Not installing ImageGlass"
}

# Install Discord
Function InstallDiscord {
	Write-Output "Installing Discord"
	winget install -e Discord.Discord
}

# Do not install Discord
Function DoNotInstallDiscord {
	Write-Output "Not installing Discord"
}

# Install Visual Studio Code
Function InstallVisualStudioCode {
	Write-Output "Installing Visual Studio Code"
	winget install -e Microsoft.VisualStudioCode --source winget
}

# Do not install Visual Studio Code
Function DoNotInstallVisualStudioCode {
	Write-Output "Not installing Visual Studio Code"
}

# Install VS Codium
Function InstallVSCodium {
	Write-Output "Installing VS Codium"
	winget install -e VSCodium.VSCodium
}

# Do not install VS Codium
Function DoNotInstallVSCodium {
	Write-Output "Not installing VS Codium"
}

# Install Voidtools Everything Search
Function InstallVoidtoolsEverything {
	Write-Output "Installing Voidtools Everything Search"
	winget install -e voidtools.Everything --source winget
}

# Do not install VS Codium
Function DoNotInstallVoidtoolsEverything {
	Write-Output "Not installing Voidtools Everything Search"
}

# Install GitHub Desktop
Function InstallGitHubDesktop {
	Write-Output "Installing GitHub Desktop"
	winget install -e GitHub.GitHubDesktop
}

# Do not install GitHub Desktop
Function DoNotInstallGitHubDesktop {
	Write-Output "Not installing GitHub Desktop"
}

# Install Translucent Taskbar
Function InstallTranslucentTB {
	Write-Output "Installing Translucent Taskbar"
	winget install -e TranslucentTB.TranslucentTB
}

# Do not install Translucent Taskbar
Function DoNotInstallTranslucentTB {
	Write-Output "Not installing Translucent Taskbar"
}

# Install Etcher USB Imager
Function InstallEtcher {
	Write-Output "Installing Etcher USB Imager"
	winget install -e Balena.Etcher
}

# Do not install Etcher USB Imager
Function DoNotInstallEtcher {
	Write-Output "Not installing Etcher USB Imager"
}

# Install PuTTY & WinSCP
Function InstallPuTTYWinSCP {
	Write-Output "Installing PuTTY & WinSCP"
	winget install -e PuTTY.PuTTY
	winget install -e WinSCP.WinSCP
}

# Do not install PuTTY & WinSCP
Function DoNotInstallPuTTYWinSCP {
	Write-Output "Not installing PuTTY & WinSCP"
}

# Install Advanced IP Scanner
Function InstallAdvancedIPScanner {
	Write-Output "Installing Advanced IP Scanner"
	winget install -e Famatech.AdvancedIPScanner
}

# Do not install Advanced IP Scanner
Function DoNotInstallAdvancedIPScanner {
	Write-Output "Not installing Advanced IP Scanner"
}

# Install ShareX Screenshot Tool
Function InstallShareX {
	Write-Output "Installing ShareX Screenshot Tool"
	winget install -e ShareX.ShareX
}

# Do not install ShareX Screenshot Tool
Function DoNotInstallShareX {
	Write-Output "Not installing ShareX Screenshot Tool"
}

# Install GIMP Image Editor
Function InstallGIMP {
	Write-Output "Installing GIMP Image Editor"
	winget install -e GIMP.GIMP
}

# Do not install GIMP Image Editor
Function DoNotInstallGIMP {
	Write-Output "Not installing GIMP Image Editor"
}

#endregion Third


#region Windows Apps

# Remove Microsoft App (Read Function name)
Function MicrosoftEdge {
	winget uninstall "Microsoft Edge"
	Write-Output "Trying to remove Microsoft Edge"
}

# Remove Microsoft App (Read Function name)
Function MicrosoftEdgeUpdate {
	winget uninstall "Microsoft Edge Update"
	Write-Output "Trying to remove Microsoft Edge Update"
}

# Remove Microsoft App (Read Function name)
Function MicrosoftEdgeWebView2Runtime {
	winget uninstall "Microsoft Edge WebView2 Runtime"
	Write-Output "Trying to remove Microsoft Edge WebView2 Runtime"
}

# Remove Microsoft App (Read Function name)
Function Cortana {
	winget uninstall "Cortana"
	Write-Output "Trying to remove Cortana"
}

# Remove Microsoft App (Read Function name)
Function MicrosoftNews {
	winget uninstall "Microsoft News"
	Write-Output "Trying to remove Microsoft News"
}

# Remove Microsoft App (Read Function name)
Function MSNWeather {
	winget uninstall "MSN Weather"
	Write-Output "Trying to remove MSN Weather"
}

# Remove Microsoft App (Read Function name)
Function Xbox {
	winget uninstall "Xbox"
	Write-Output "Trying to remove Xbox"
}

# Remove Microsoft App (Read Function name)
Function GetHelp {
	winget uninstall "Get Help"
	Write-Output "Trying to remove Get Help"
}

# Remove Microsoft App (Read Function name)
Function MicrosoftTips {
	winget uninstall "Microsoft Tips"
	Write-Output "Trying to remove Microsoft Tips"
}

# Remove Microsoft App (Read Function name)
Function HEIFImageExtensions {
	winget uninstall "HEIF Image Extensions"
	Write-Output "Trying to remove HEIF Image Extensions"
}

# Remove Microsoft App (Read Function name)
Function Office {
	winget uninstall "Office"
	Write-Output "Trying to remove Office"
}

# Remove Microsoft App (Read Function name)
Function MicrosoftSolitaireCollection {
	winget uninstall "Microsoft Solitaire Collection"
	Write-Output "Trying to remove Microsoft Solitaire Collection"
}

# Remove Microsoft App (Read Function name)
Function MicrosoftStickyNotes {
	winget uninstall "Microsoft Sticky Notes"
	Write-Output "Trying to remove Microsoft Sticky Notes"
}

# Remove Microsoft App (Read Function name)
Function Paint {
	winget uninstall "Paint"
	Write-Output "Trying to remove Paint"
}

# Remove Microsoft App (Read Function name)
Function MicrosoftPeople {
	winget uninstall "Microsoft People"
	Write-Output "Trying to remove Microsoft People"
}

# Remove Microsoft App (Read Function name)
Function PowerAutomate {
	winget uninstall "Power Automate"
	Write-Output "Trying to remove Power Automate"
}

# Remove Microsoft App (Read Function name)
Function SnippingTool {
	winget uninstall "Snipping Tool"
	Write-Output "Trying to remove Snipping Tool"
}

# Remove Microsoft App (Read Function name)
Function WindowsSecurity {
	winget uninstall "Windows Security"
	Write-Output "Trying to remove Windows Security"
}

# Remove Microsoft App (Read Function name)
Function StoreExperienceHost {
	winget uninstall "Store Experience Host"
	Write-Output "Trying to remove Store Experience Host"
}

# Remove Microsoft App (Read Function name)
Function MicrosoftToDo {
	winget uninstall "Microsoft To Do"
	Write-Output "Trying to remove Microsoft To Do"
}

# Remove Microsoft App (Read Function name)
Function VP9VideoExtensions {
	winget uninstall "VP9 Video Extensions"
	Write-Output "Trying to remove VP9 Video Extensions"
}

# Remove Microsoft App (Read Function name)
Function WebMediaExtensions {
	winget uninstall "Web Media Extensions"
	Write-Output "Trying to remove Web Media Extensions"
}

# Remove Microsoft App (Read Function name)
Function WebpImageExtensions {
	winget uninstall "Webp Image Extensions"
	Write-Output "Trying to remove Webp Image Extensions"
}

# Remove Microsoft App (Read Function name)
Function MicrosoftPhotos {
	winget uninstall "Microsoft Photos"
	Write-Output "Trying to remove Microsoft Photos"
}

# Remove Microsoft App (Read Function name)
Function WindowsAlarmsClock {
	winget uninstall "Windows Alarms & Clock"
	Write-Output "Trying to remove Windows Alarms & Clock"
}

# Remove Microsoft App (Read Function name)
Function WindowsCalculator {
	winget uninstall "Windows Calculator"
	Write-Output "Trying to remove Windows Calculator"
}

# Remove Microsoft App (Read Function name)
Function WindowsCamera {
	winget uninstall "Windows Camera"
	Write-Output "Trying to remove Windows Camera"
}

# Remove Microsoft App (Read Function name)
Function FeedbackHub {
	winget uninstall "Feedback Hub"
	Write-Output "Trying to remove Feedback Hub"
}

# Remove Microsoft App (Read Function name)
Function WindowsMaps {
	winget uninstall "Windows Maps"
	Write-Output "Trying to remove Windows Maps"
}

# Remove Microsoft App (Read Function name)
Function WindowsNotepad {
	winget uninstall "Windows Notepad"
	Write-Output "Trying to remove Windows Notepad"
}

# Remove Microsoft App (Read Function name)
Function WindowsVoiceRecorder {
	winget uninstall "Windows Voice Recorder"
	Write-Output "Trying to remove Windows Voice Recorder"
}

# Remove Microsoft App (Read Function name)
Function XboxTCUI {
	winget uninstall "Xbox TCUI"
	Write-Output "Trying to remove Xbox TCUI"
}

# Remove Microsoft App (Read Function name)
Function XboxGameBarPlugin {
	winget uninstall "Xbox Game Bar Plugin"
	Write-Output "Trying to remove Xbox Game Bar Plugin"
}

# Remove Microsoft App (Read Function name)
Function XboxGameBar {
	winget uninstall "Xbox Game Bar"
	Write-Output "Trying to remove Xbox Game Bar"
}

# Remove Microsoft App (Read Function name)
Function XboxIdentityProvider {
	winget uninstall "Xbox Identity Provider"
	Write-Output "Trying to remove Xbox Identity Provider"
}

# Remove Microsoft App (Read Function name)
Function XboxGameSpeechWindow {
	winget uninstall "Xbox Game Speech Window"
	Write-Output "Trying to remove Xbox Game Speech Window"
}

# Remove Microsoft App (Read Function name)
Function YourPhone {
	winget uninstall "Your Phone"
	Write-Output "Trying to remove Your Phone"
}

# Remove Microsoft App (Read Function name)
Function GrooveMusic {
	winget uninstall "Groove Music"
	Write-Output "Trying to remove Groove Music"
}

# Remove Microsoft App (Read Function name)
Function MoviesTV {
	winget uninstall "Movies & TV"
	Write-Output "Trying to remove Movies & TV"
}

# Remove Microsoft App (Read Function name)
Function MicrosoftTeams {
	winget uninstall "Microsoft Teams"
	Write-Output "Trying to remove Microsoft Teams"
}

# Remove Microsoft App (Read Function name)
Function WindowsWebExperiencePack {
	winget uninstall "Windows Web Experience Pack"
	Write-Output "Trying to remove Windows Web Experience Pack"
}

# Remove Microsoft App (Read Function name)
Function MailCalendar {
	winget uninstall "Mail and Calendar"
	Write-Output "Trying to remove Mail and Calendar"
}

# Remove Microsoft App (Read Function name)
Function MicrosoftStore {
	winget uninstall "Microsoft Store"
	Write-Output "Trying to remove Microsoft Store"
}

# Remove Microsoft App (Read Function name)
Function WindowsTerminal {
	winget uninstall "Windows Terminal"
	Write-Output "Trying to remove Windows Terminal"
}

# Remove Microsoft App (Read Function name)
Function MicrosoftBingNews {
    Get-AppxPackage -Name Microsoft.BingNews| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like Microsoft.BingNews | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove Microsoft.BingNews."
}

# Remove Microsoft App (Read Function name)
Function MicrosoftGetHelp {
    Get-AppxPackage -Name Microsoft.GetHelp| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like Microsoft.GetHelp | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove Microsoft.GetHelp."
}

# Remove Microsoft App (Read Function name)
Function MicrosoftGetstarted {
    Get-AppxPackage -Name Microsoft.Getstarted| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like Microsoft.Getstarted | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove Microsoft.Getstarted."
}

# Remove Microsoft App (Read Function name)
Function MicrosoftMessaging {
    Get-AppxPackage -Name Microsoft.Messaging"| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like Microsoft.Messaging" | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove Microsoft.Messaging."
}

# Remove Microsoft App (Read Function name)
Function MicrosoftMicrosoft3DViewer {
    Get-AppxPackage -Name Microsoft.Microsoft3DViewer| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like Microsoft.Microsoft3DViewer | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove Microsoft.Microsoft3DViewer."
}

# Remove Microsoft App (Read Function name)
Function MicrosoftMicrosoftSolitaireCollection {
    Get-AppxPackage -Name Microsoft.MicrosoftSolitaireCollection| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like Microsoft.MicrosoftSolitaireCollection | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove Microsoft.MicrosoftSolitaireCollection."
}

# Remove Microsoft App (Read Function name)
Function MicrosoftNetworkSpeedTest {
    Get-AppxPackage -Name Microsoft.NetworkSpeedTest| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like Microsoft.NetworkSpeedTest | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove Microsoft.NetworkSpeedTest."
}

# Remove Microsoft App (Read Function name)
Function MicrosoftNews {
    Get-AppxPackage -Name Microsoft.News| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like Microsoft.News | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove Microsoft.News."
}

# Remove Microsoft App (Read Function name)
Function MicrosoftOfficeLens {
    Get-AppxPackage -Name Microsoft.Office.Lens| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like Microsoft.Office.Lens | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove Microsoft.Office.Lens."
}

# Remove Microsoft App (Read Function name)
Function MicrosoftOfficeSway {
    Get-AppxPackage -Name Microsoft.Office.Sway| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like Microsoft.Office.Sway | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove Microsoft.Office.Sway."
}

# Remove Microsoft App (Read Function name)
Function MicrosoftOneConnect {
    Get-AppxPackage -Name Microsoft.OneConnect| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like Microsoft.OneConnect | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove Microsoft.OneConnect."
}

# Remove Microsoft App (Read Function name)
Function MicrosoftPrint3D {
    Get-AppxPackage -Name Microsoft.Print3D| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like Microsoft.Print3D | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove Microsoft.Print3D."
}

# Remove Microsoft App (Read Function name)
Function MicrosoftSkypeApp {
    Get-AppxPackage -Name Microsoft.SkypeApp| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like Microsoft.SkypeApp | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove Microsoft.SkypeApp."
}

# Remove Microsoft App (Read Function name)
Function MicrosoftStorePurchaseApp {
    Get-AppxPackage -Name Microsoft.StorePurchaseApp| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like Microsoft.StorePurchaseApp | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove Microsoft.StorePurchaseApp."
}

# Remove Microsoft App (Read Function name)
Function MicrosoftWhiteboard {
    Get-AppxPackage -Name Microsoft.Whiteboard| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like Microsoft.Whiteboard | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove Microsoft.Whiteboard."
}

# Remove Microsoft App (Read Function name)
Function MicrosoftWindowsAlarms {
    Get-AppxPackage -Name Microsoft.WindowsAlarms| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like Microsoft.WindowsAlarms | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove Microsoft.WindowsAlarms."
}

# Remove Microsoft App (Read Function name)
Function microsoftwindowscommunicationsapps {
    Get-AppxPackage -Name microsoft.windowscommunicationsapps| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like microsoft.windowscommunicationsapps | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove microsoft.windowscommunicationsapps."
}

# Remove Microsoft App (Read Function name)
Function MicrosoftWindowsFeedbackHub {
    Get-AppxPackage -Name Microsoft.WindowsFeedbackHub| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like Microsoft.WindowsFeedbackHub | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove Microsoft.WindowsFeedbackHub."
}

# Remove Microsoft App (Read Function name)
Function MicrosoftWindowsMaps {
    Get-AppxPackage -Name Microsoft.WindowsMaps| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like Microsoft.WindowsMaps | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove Microsoft.WindowsMaps."
}

# Remove Microsoft App (Read Function name)
Function MicrosoftWindowsSoundRecorder {
    Get-AppxPackage -Name Microsoft.WindowsSoundRecorder| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like Microsoft.WindowsSoundRecorder | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove Microsoft.WindowsSoundRecorder."
}

# Remove Microsoft App (Read Function name)
Function MicrosoftZuneMusic {
    Get-AppxPackage -Name Microsoft.ZuneMusic| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like Microsoft.ZuneMusic | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove Microsoft.ZuneMusic."
}

# Remove Microsoft App (Read Function name)
Function MicrosoftZuneVideo {
    Get-AppxPackage -Name Microsoft.ZuneVideo| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like Microsoft.ZuneVideo | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove Microsoft.ZuneVideo."
}

# Remove Microsoft App (Read Function name)
Function EclipseManager {
    Get-AppxPackage -Name *EclipseManager*| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like *EclipseManager* | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove *EclipseManager*."
}

# Remove Microsoft App (Read Function name)
Function ActiproSoftwareLLC {
    Get-AppxPackage -Name *ActiproSoftwareLLC*| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like *ActiproSoftwareLLC* | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove *ActiproSoftwareLLC*."
}

# Remove Microsoft App (Read Function name)
Function AdobeSystemsIncorporatedAdobePhotoshopExpress {
    Get-AppxPackage -Name *AdobeSystemsIncorporated.AdobePhotoshopExpress*| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like *AdobeSystemsIncorporated.AdobePhotoshopExpress* | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove *AdobeSystemsIncorporated.AdobePhotoshopExpress*."
}

# Remove Microsoft App (Read Function name)
Function Duolingo_LearnLanguagesforFree {
    Get-AppxPackage -Name *Duolingo-LearnLanguagesforFree*| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like *Duolingo-LearnLanguagesforFree* | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove *Duolingo-LearnLanguagesforFree*."
}

# Remove Microsoft App (Read Function name)
Function PandoraMediaInc {
    Get-AppxPackage -Name *PandoraMediaInc*| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like *PandoraMediaInc* | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove *PandoraMediaInc*."
}

# Remove Microsoft App (Read Function name)
Function CandyCrush {
    Get-AppxPackage -Name *CandyCrush*| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like *CandyCrush* | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove *CandyCrush*."
}

# Remove Microsoft App (Read Function name)
Function BubbleWitch3Saga {
    Get-AppxPackage -Name *BubbleWitch3Saga*| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like *BubbleWitch3Saga* | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove *BubbleWitch3Saga*."
}

# Remove Microsoft App (Read Function name)
Function Wunderlist {
    Get-AppxPackage -Name *Wunderlist*| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like *Wunderlist* | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove *Wunderlist*."
}

# Remove Microsoft App (Read Function name)
Function Flipboard {
    Get-AppxPackage -Name *Flipboard*| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like *Flipboard* | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove *Flipboard*."
}

# Remove Microsoft App (Read Function name)
Function Twitter {
    Get-AppxPackage -Name *Twitter*| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like *Twitter* | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove *Twitter*."
}

# Remove Microsoft App (Read Function name)
Function Facebook {
    Get-AppxPackage -Name *Facebook*| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like *Facebook* | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove *Facebook*."
}

# Remove Microsoft App (Read Function name)
Function Spotify {
    Get-AppxPackage -Name *Spotify*| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like *Spotify* | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove *Spotify*."
}

# Remove Microsoft App (Read Function name)
Function RoyalRevolt {
    Get-AppxPackage -Name *RoyalRevolt*| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like *RoyalRevolt* | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove *RoyalRevolt*."
}

# Remove Microsoft App (Read Function name)
Function Sway {
    Get-AppxPackage -Name *Sway*| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like *Sway* | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove *Sway*."
}

# Remove Microsoft App (Read Function name)
Function SpeedTest {
    Get-AppxPackage -Name *SpeedTest*| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like *SpeedTest* | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove *SpeedTest*."
}

# Remove Microsoft App (Read Function name)
Function Dolby {
    Get-AppxPackage -Name *Dolby*| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like *Dolby* | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove *Dolby*."
}

# Remove Microsoft App (Read Function name)
Function MicrosoftAdvertisingXaml_10171250_x64__8wekyb3d8bbwe {
    Get-AppxPackage -Name *Microsoft.Advertising.Xaml_10.1712.5.0_x64__8wekyb3d8bbwe*| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like *Microsoft.Advertising.Xaml_10.1712.5.0_x64__8wekyb3d8bbwe* | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove *Microsoft.Advertising.Xaml_10.1712.5.0_x64__8wekyb3d8bbwe*."
}

# Remove Microsoft App (Read Function name)
Function MicrosoftAdvertisingXaml_10171250_x86__8wekyb3d8bbwe {
    Get-AppxPackage -Name *Microsoft.Advertising.Xaml_10.1712.5.0_x86__8wekyb3d8bbwe*| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like *Microsoft.Advertising.Xaml_10.1712.5.0_x86__8wekyb3d8bbwe* | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove *Microsoft.Advertising.Xaml_10.1712.5.0_x86__8wekyb3d8bbwe*."
}

# Remove Microsoft App (Read Function name)
Function MicrosoftBingWeather {
    Get-AppxPackage -Name *Microsoft.BingWeather*| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like *Microsoft.BingWeather* | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove *Microsoft.BingWeather*."
}

# Remove Microsoft App (Read Function name)
Function MicrosoftMSPaint {
    Get-AppxPackage -Name *Microsoft.MSPaint*| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like *Microsoft.MSPaint* | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove *Microsoft.MSPaint*."
}

# Remove Microsoft App (Read Function name)
Function MicrosoftMicrosoftStickyNotes {
    Get-AppxPackage -Name *Microsoft.MicrosoftStickyNotes*| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like *Microsoft.MicrosoftStickyNotes* | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove *Microsoft.MicrosoftStickyNotes*."
}

# Remove Microsoft App (Read Function name)
Function MicrosoftWindowsPhotos {
    Get-AppxPackage -Name *Microsoft.Windows.Photos*| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like *Microsoft.Windows.Photos* | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove *Microsoft.Windows.Photos*."
}

# Remove Microsoft App (Read Function name)
Function MicrosoftWindowsCalculator {
    Get-AppxPackage -Name *Microsoft.WindowsCalculator*| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like *Microsoft.WindowsCalculator* | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove *Microsoft.WindowsCalculator*."
}

# Remove Microsoft App (Read Function name)
Function MicrosoftWindowsStore {
    Get-AppxPackage -Name *Microsoft.WindowsStore*| Remove-AppxPackage
    Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like *Microsoft.WindowsStore* | Remove-AppxProvisionedPackage -Online
    Write-Output "Trying to remove *Microsoft.WindowsStore*."
}

#endregion Windows Apps

#region Privacy & Telemetry

# Disable the Connected User Experiences and Telemetry (DiagTrack) service, and block connection for the Unified Telemetry Client Outbound Traffic
Function DisableDiagTrackService {
	Write-Output "Disabling DiagTrack Service ..."
	# Connected User Experiences and Telemetry
	Get-Service -Name DiagTrack | Stop-Service -Force
	Get-Service -Name DiagTrack | Set-Service -StartupType Disabled

	# Block connection for the Unified Telemetry Client Outbound Traffic
	Get-NetFirewallRule -Group DiagTrack | Set-NetFirewallRule -Enabled False -Action Block
}

# Enable the Connected User Experiences and Telemetry (DiagTrack) service, and allow connection for the Unified Telemetry Client Outbound Traffic
Function EnableDiagTrackService {
	Write-Output "Enabling DiagTrack Service ..."
	# Connected User Experiences and Telemetry
	Get-Service -Name DiagTrack | Set-Service -StartupType Automatic
	Get-Service -Name DiagTrack | Start-Service

	# Allow connection for the Unified Telemetry Client Outbound Traffic
	Get-NetFirewallRule -Group DiagTrack | Set-NetFirewallRule -Enabled True -Action Allow
}

# Set the diagnostic data collection to minimum
Function MinimalDiagnosticDataLevel {
	Write-Output "Setting Minimal Diagnostic Data Level ..."
	if (Get-WindowsEdition -Online | Where-Object -FilterScript {$_.Edition -like "Enterprise*" -or $_.Edition -eq "Education"})
	{
		# Diagnostic data off
		New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 0 -Force
	}
	else
	{
		# Send required diagnostic data
		New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 1 -Force
	}
	New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 1 -Force

	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Name ShowedToastAtLevel -PropertyType DWord -Value 1 -Force
}

# Set the diagnostic data collection to default
Function DefaultDiagnosticDataLevel {
	Write-Output "Setting Default Diagnostic Data Level ..."
	# Optional diagnostic data
	New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 3 -Force
	New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 3 -Force

	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Name ShowedToastAtLevel -PropertyType DWord -Value 3 -Force
}

# Turn off Windows Error Reporting
Function DisableErrorReporting {
	Write-Output "Disable Error Reporting ..."
	if ((Get-WindowsEdition -Online).Edition -notmatch "Core")
	{
		Get-ScheduledTask -TaskName QueueReporting | Disable-ScheduledTask
		New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\Windows Error Reporting" -Name Disabled -PropertyType DWord -Value 1 -Force
	}

	Get-Service -Name WerSvc | Stop-Service -Force
	Get-Service -Name WerSvc | Set-Service -StartupType Disabled
}

# Turn on Windows Error Reporting
Function EnableErrorReporting {
	Write-Output "Enable Error Reporting ..."
	Get-ScheduledTask -TaskName QueueReporting | Enable-ScheduledTask
	Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore

	Get-Service -Name WerSvc | Set-Service -StartupType Manual
	Get-Service -Name WerSvc | Start-Service
}

# Change the feedback frequency to "Never"
Function NeverFeedbackFrequency {
	Write-Output "Setting Never Feedback Frequency ..."
	if (-not (Test-Path -Path HKCU:\SOFTWARE\Microsoft\Siuf\Rules))
	{
		New-Item -Path HKCU:\SOFTWARE\Microsoft\Siuf\Rules -Force
	}
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Siuf\Rules -Name NumberOfSIUFInPeriod -PropertyType DWord -Value 0 -Force
}

# Change feedback frequency to "Automatically"
Function AutomaticallyFeedbackFrequency {
	Write-Output "Setting Automatically Feedback Frequency ..."
	Remove-Item -Path HKCU:\SOFTWARE\Microsoft\Siuf\Rules -Force -ErrorAction Ignore
}

# Do not use sign-in info to automatically finish setting up device after an update
Function DisableSigninInfo {
	Write-Output "Disable Signin Info ..."
	$SID = (Get-CimInstance -ClassName Win32_UserAccount | Where-Object -FilterScript {$_.Name -eq $env:USERNAME}).SID
	if (-not (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\UserARSO\$SID"))
	{
		New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\UserARSO\$SID" -Force
	}
	New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\UserARSO\$SID" -Name OptOut -PropertyType DWord -Value 1 -Force	
}

# Use sign-in info to automatically finish setting up device after an update
Function EnableSigninInfo {
	Write-Output "Enable Signin Info ..."
	$SID = (Get-CimInstance -ClassName Win32_UserAccount | Where-Object -FilterScript {$_.Name -eq $env:USERNAME}).SID
	Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\UserARSO\$SID" -Name OptOut -Force -ErrorAction Ignore
}

# Do not let websites show me locally relevant content by accessing my language list
Function DisableLanguageListAccess {
	Write-Output "Disable Language List Access ..."
	New-ItemProperty -Path "HKCU:\Control Panel\International\User Profile" -Name HttpAcceptLanguageOptOut -PropertyType DWord -Value 1 -Force
}

# Let websites show me locally relevant content by accessing language my list
Function EnableLanguageListAccess {
	Write-Output "Enable Language List Access ..."
	Remove-ItemProperty -Path "HKCU:\Control Panel\International\User Profile" -Name HttpAcceptLanguageOptOut -Force -ErrorAction Ignore
}

# Do not let apps show me personalized ads by using my advertising ID
Function DisableAdvertisingID {
	Write-Output "Disable Advertising ID ..."
	if (-not (Test-Path -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo))
	{
		New-Item -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Force
	}
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -PropertyType DWord -Value 0 -Force		
}

# Let apps show me personalized ads by using my advertising ID
Function EnableAdvertisingID {
	Write-Output "Enable Advertising ID ..."
	if (-not (Test-Path -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo))
	{
		New-Item -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Force
	}
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -PropertyType DWord -Value 1 -Force		
}

# Hide the Windows welcome experiences after updates and occasionally when I sign in to highlight what's new and suggested
Function HideWindowsWelcomeExperience {
	Write-Output "Hide Windows Welcome Experience ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name SubscribedContent-310093Enabled -PropertyType DWord -Value 0 -Force
}

# Show the Windows welcome experiences after updates and occasionally when I sign in to highlight what's new and suggested
Function ShowWindowsWelcomeExperience {
	Write-Output "Show Windows Welcome Experience ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name SubscribedContent-310093Enabled -PropertyType DWord -Value 1 -Force
}

# Do not get tip and suggestions when I use Windows
Function DisableWindowsTips {
	Write-Output "Disable Windows Tips ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name SubscribedContent-338389Enabled -PropertyType DWord -Value 0 -Force
}

# Get tip and suggestions when I use Windows
Function EnableWindowsTips {
	Write-Output "Enable Windows Tips ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name SubscribedContent-338389Enabled -PropertyType DWord -Value 1 -Force		
}

# Hide from me suggested content in the Settings app
Function HideSettingsSuggestedContent {
	Write-Output "Hide Settings Suggested Content ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name SubscribedContent-338393Enabled -PropertyType DWord -Value 0 -Force
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name SubscribedContent-353694Enabled -PropertyType DWord -Value 0 -Force
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name SubscribedContent-353696Enabled -PropertyType DWord -Value 0 -Force
}

# Show me suggested content in the Settings app
Function ShowSettingsSuggestedContent {
	Write-Output "Show Settings Suggested Content ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name SubscribedContent-338393Enabled -PropertyType DWord -Value 1 -Force
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name SubscribedContent-353694Enabled -PropertyType DWord -Value 1 -Force
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name SubscribedContent-353696Enabled -PropertyType DWord -Value 1 -Force		
}

# Turn off automatic installing suggested apps
Function DisableAppsSilentInstalling {
	Write-Output "Disable Apps Silent Installing ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name SilentInstalledAppsEnabled -PropertyType DWord -Value 0 -Force		
}

# Turn on automatic installing suggested apps
Function EnableAppsSilentInstalling {
	Write-Output "Enable Apps Silent Installing ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager -Name SilentInstalledAppsEnabled -PropertyType DWord -Value 1 -Force		
}

# Disable suggestions on how I can set up my device
Function DisableWhatsNewInWindows {
	Write-Output "Disable Whats New In Windows ..."
	if (-not (Test-Path -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\UserProfileEngagement))
	{
		New-Item -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Force
	}
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Name ScoobeSystemSettingEnabled -PropertyType DWord -Value 0 -Force
}

# Offer suggestions on how I can set up my device
Function EnableWhatsNewInWindows {
	Write-Output "Enable Whats New In Windows ..."
	if (-not (Test-Path -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\UserProfileEngagement))
	{
		New-Item -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Force
	}
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\UserProfileEngagement -Name ScoobeSystemSettingEnabled -PropertyType DWord -Value 1 -Force		
}

# Do not let Microsoft use your diagnostic data for personalized tips, ads, and recommendations
Function DisableTailoredExperiences {
	Write-Output "Disable Tailored Experiences ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Privacy -Name TailoredExperiencesWithDiagnosticDataEnabled -PropertyType DWord -Value 0 -Force		
}

# Let Microsoft use your diagnostic data for personalized tips, ads, and recommendations
Function EnableTailoredExperiences {
	Write-Output "Enable Tailored Experiences ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Privacy -Name TailoredExperiencesWithDiagnosticDataEnabled -PropertyType DWord -Value 1 -Force		
}

# Disable Bing search in the Start Menu
Function DisableBingSearch {
	Write-Output "Disable Bing Search ..."
	if (-not (Test-Path -Path HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer))
	{
		New-Item -Path HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Force
	}
	New-ItemProperty -Path HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableSearchBoxSuggestions -PropertyType DWord -Value 1 -Force		
}

# Enable Bing search in the Start Menu
Function EnableBingSearch {
	Write-Output "Enable Bing Search ..."
	Remove-ItemProperty -Path HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name DisableSearchBoxSuggestions -Force -ErrorAction Ignore	
}

#endregion Privacy & Telemetry

#region UI & Personalization

# Show the "This PC" icon on Desktop
Function ShowThisPC {
	Write-Output "Show This PC ..."
	if (-not (Test-Path -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel))
	{
		New-Item -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel -Force
	}
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel -Name "{20D04FE0-3AEA-1069-A2D8-08002B30309D}" -PropertyType DWord -Value 0 -Force
}

# Hide the "This PC" icon on Desktop
Function HideThisPC {
	Write-Output "Hide This PC ..."
	Remove-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel -Name "{20D04FE0-3AEA-1069-A2D8-08002B30309D}" -Force -ErrorAction Ignore
}

# Enable the Windows 10 File Explorer
Function EnableWindows10FileExplorer {
	Write-Output "Enable Windows 10 File Explorer ..."
	if (-not (Test-Path -Path "HKCU:\Software\Classes\CLSID\{d93ed569-3b3e-4bff-8355-3c44f6a52bb5}\InprocServer32"))
	{
		New-Item -Path "HKCU:\Software\Classes\CLSID\{d93ed569-3b3e-4bff-8355-3c44f6a52bb5}\InprocServer32" -Force
	}
	New-ItemProperty -Path "HKCU:\Software\Classes\CLSID\{d93ed569-3b3e-4bff-8355-3c44f6a52bb5}\InprocServer32" -Name "(default)" -PropertyType String -Value "" -Force
}

# Disable the Windows 10 File Explorer
Function DisableWindows10FileExplorer {
	Write-Output "Disable Windows 10 File Explorer ..."
	Remove-Item -Path "HKCU:\Software\Classes\CLSID\{d93ed569-3b3e-4bff-8355-3c44f6a52bb5}" -Recurse -Force -ErrorAction Ignore
}

# Do not use item check boxes
Function DisableCheckBoxes {
	Write-Output "Disable CheckBoxes ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name AutoCheckSelect -PropertyType DWord -Value 0 -Force	
}

# Use check item check boxes
Function EnableCheckBoxes {
	Write-Output "Enable CheckBoxes ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name AutoCheckSelect -PropertyType DWord -Value 1 -Force	
}

# Show hidden files, folders, and drives
Function EnableHiddenItems {
	Write-Output "Enable Hidden Items ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name Hidden -PropertyType DWord -Value 1 -Force		
}

# Do not show hidden files, folders, and drives
Function DisableHiddenItems {
	Write-Output "Disable Hidden Items ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name Hidden -PropertyType DWord -Value 2 -Force
}

# Show file name extensions
Function ShowFileExtensions {
	Write-Output "Show File Extensions ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name HideFileExt -PropertyType DWord -Value 0 -Force		
}

# Hide file name extensions
Function HideFileExtensions {
	Write-Output "Hide File Extensions ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name HideFileExt -PropertyType DWord -Value 1 -Force		
}

# Show folder merge conflicts
Function ShowMergeConflicts {
	Write-Output "Show Merge Conflicts ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name HideMergeConflicts -PropertyType DWord -Value 0 -Force
}

# Hide folder merge conflicts
Function HideMergeConflicts {
	Write-Output "Hide Merge Conflicts ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name HideMergeConflicts -PropertyType DWord -Value 1 -Force
}

# Open File Explorer to "This PC"
Function ThisPCOpenFileExplorerTo {
	Write-Output "This PC Open File Explorer To ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name LaunchTo -PropertyType DWord -Value 1 -Force
}

# Open File Explorer to Quick access
Function QuickAccessOpenFileExplorerTo {
	Write-Output "Quick Access Open File Explorer To ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name LaunchTo -PropertyType DWord -Value 2 -Force		
}

# Disable the File Explorer compact mode
Function DisableFileExplorerCompactMode {
	Write-Output "Disable File Explorer Compact Mode ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name UseCompactMode -PropertyType DWord -Value 1 -Force
}

# Enable the File Explorer compact mode
Function EnableFileExplorerCompactMode {
	Write-Output "Enable File Explorer Compact Mode ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name UseCompactMode -PropertyType DWord -Value 0 -Force
}

# Do not show sync provider notification within File Explorer
Function HideOneDriveFileExplorerAd {
	Write-Output "Hide OneDrive File Explorer Ad ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name ShowSyncProviderNotifications -PropertyType DWord -Value 0 -Force
}

# Show sync provider notification within File Explorer
Function ShowOneDriveFileExplorerAd {
	Write-Output "Show OneDrive File Explorer Ad ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name ShowSyncProviderNotifications -PropertyType DWord -Value 1 -Force
}

# When I snap a window, do not show what I can snap next to it
Function DisableSnapAssist {
	Write-Output "Disable Snap Assist ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name SnapAssist -PropertyType DWord -Value 0 -Force		
}

# When I snap a window, show what I can snap next to it
Function EnableSnapAssist {
	Write-Output "Enable Snap Assist ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name SnapAssist -PropertyType DWord -Value 1 -Force
}

# Show snap layouts when I hover over a windows's maximize button
Function EnableSnapAssistFlyout {
	Write-Output "Enable Snap Assist Flyout ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name EnableSnapAssistFlyout -PropertyType DWord -Value 1 -Force
}

# Hide snap layouts when I hover over a windows's maximize button
Function DisableSnapAssistFlyout {
	Write-Output "Disable Snap Assist Flyout ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name EnableSnapAssistFlyout -PropertyType DWord -Value 0 -Force
}

# Show the file transfer dialog box in the detailed mode
Function DetailedFileTransferDialog {
	Write-Output "Setting Detailed File Transfer Dialog ..."
	if (-not (Test-Path -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager))
	{
		New-Item -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Force
	}
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Name EnthusiastMode -PropertyType DWord -Value 1 -Force	
}

# Show the file transfer dialog box in the compact mode
Function CompactFileTransferDialog {
	Write-Output "Setting Compact File Transfer Dialog ..."
	if (-not (Test-Path -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager))
	{
		New-Item -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Force
	}
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager -Name EnthusiastMode -PropertyType DWord -Value 0 -Force
}

# Expand the Windows 10 File Explorer ribbon
Function ExpandedWindows10FileExplorerRibbon {
	Write-Output "Setting Expanded Windows 10 File Explorer Ribbon ..."
	if (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{e2bf9676-5f8f-435c-97eb-11607a5bedf7}" -ErrorAction Ignore)
	{
		if (-not (Test-Path -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Ribbon))
		{
		New-Item -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Ribbon -Force
		}
		New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Ribbon -Name MinimizedStateTabletModeOff -PropertyType DWord -Value 0 -Force
	}
}

# Minimize the Windows 10 File Explorer ribbon
Function MinimizedWindows10FileExplorerRibbon {
	Write-Output "Setting Minimized Windows 10 File Explorer Ribbon ..."
	if (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{e2bf9676-5f8f-435c-97eb-11607a5bedf7}" -ErrorAction Ignore)
	{
		if (-not (Test-Path -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Ribbon))
		{
			New-Item -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Ribbon -Force
		}
		New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Ribbon -Name MinimizedStateTabletModeOff -PropertyType DWord -Value 1 -Force
	}
}

# Display the recycle bin files delete confirmation dialog
Function EnableRecycleBinDeleteConfirmation {
	Write-Output "Enable Recycle Bin Delete Confirmation ..."
	$ShellState = Get-ItemPropertyValue -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer -Name ShellState
	$ShellState[4] = 51
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer -Name ShellState -PropertyType Binary -Value $ShellState -Force
}

# Do not display the recycle bin files delete confirmation dialog
Function DisableRecycleBinDeleteConfirmation {
	Write-Output "Disable Recycle Bin Delete Confirmation ..."
	$ShellState = Get-ItemPropertyValue -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer -Name ShellState
	$ShellState[4] = 55
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer -Name ShellState -PropertyType Binary -Value $ShellState -Force	
}

# Hide recently used files in Quick access
Function HideQuickAccessRecentFiles {
	Write-Output "Hide Quick Access Recent Files ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer -Name ShowRecent -PropertyType DWord -Value 0 -Force
}

# Show recently used files in Quick access
Function ShowQuickAccessRecentFiles {
	Write-Output "Show Quick Access Recent Files ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer -Name ShowRecent -PropertyType DWord -Value 1 -Force
}

# Set the taskbar alignment to the left
Function LeftTaskbarAlignment {
	Write-Output "Setting Left Taskbar Alignment ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarAl -PropertyType DWord -Value 0 -Force
}

# Set the taskbar alignment to the center
Function CenterTaskbarAlignment {
	Write-Output "Setting Center Taskbar Alignment ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarAl -PropertyType DWord -Value 1 -Force
}

# Hide the search icon on the taskbar
Function HideTaskbarSearch {
	Write-Output "Hide Taskbar Search ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search -Name SearchboxTaskbarMode -PropertyType DWord -Value 0 -Force
}

# Show the search icon on the taskbar
Function ShowTaskbarSearch {
	Write-Output "Show Taskbar Search ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search -Name SearchboxTaskbarMode -PropertyType DWord -Value 1 -Force
}

# Hide the Task view button on the taskbar
Function HideTaskViewButton {
	Write-Output "Hide Task View Button ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name ShowTaskViewButton -PropertyType DWord -Value 0 -Force
}

# Show the Task View button on the taskbar
Function ShowTaskViewButton {
	Write-Output "Show Task View Button ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name ShowTaskViewButton -PropertyType DWord -Value 1 -Force
}

# Hide the widgets icon on the taskbar
Function HideTaskbarWidgets {
	Write-Output "Hide Taskbar Widgets ..."
	if (Get-AppxPackage -Name MicrosoftWindows.Client.WebExperience)
	{
		New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarDa -PropertyType DWord -Value 0 -Force
	}
}

# Show the widgets icon on the taskbar
Function ShowTaskbarWidgets {
	Write-Output "Show Taskbar Widgets ..."
	if (Get-AppxPackage -Name MicrosoftWindows.Client.WebExperience)
	{
		New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarDa -PropertyType DWord -Value 1 -Force
	}
}

# Hide the Chat icon (Microsoft Teams) on the taskbar
Function HideTaskbarChat {
	Write-Output "Hide Taskbar Chat ..."
	New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarMn -PropertyType DWord -Value 0 -Force
}

# Show the Chat icon (Microsoft Teams) on the taskbar
Function ShowTaskbarChat {
	Write-Output "Show Taskbar Chat ..."
	New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarMn -PropertyType DWord -Value 1 -Force
}

# Set the default Windows mode to dark
Function DarkWindowsColorMode {
	Write-Output "Setting Dark Windows Color Mode ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name SystemUsesLightTheme -PropertyType DWord -Value 0 -Force
}

# Set the default Windows mode to light
Function LightWindowsColorMode {
	Write-Output "Setting Light Windows Color Mode ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name SystemUsesLightTheme -PropertyType DWord -Value 1 -Force
}

# Set the default app mode to dark
Function DarkAppColorMode {
	Write-Output "Setting Dark App Color Mode ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -PropertyType DWord -Value 0 -Force
}

# Set the default app mode to light
Function LightAppColorMode {
	Write-Output "Setting Light App Color Mode ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -PropertyType DWord -Value 1 -Force
}

# Disable first sign-in animation after the upgrade
Function DisableFirstLogonAnimation {
	Write-Output "Disable First Logon Animation ..."
	New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name EnableFirstLogonAnimation -PropertyType DWord -Value 0 -Force
}

# Enable first sign-in animation after the upgrade
Function EnableFirstLogonAnimation {
	Write-Output "Enable First Logon Animation ..."
	New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name EnableFirstLogonAnimation -PropertyType DWord -Value 1 -Force
}

# Set the quality factor of the JPEG desktop wallpapers to maximum
Function MaxJPEGWallpapersQuality {
	Write-Output "Setting Max JPEG Wallpapers Quality ..."
	New-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name JPEGImportQuality -PropertyType DWord -Value 100 -Force
}

# Set the quality factor of the JPEG desktop wallpapers to default
Function DefaultJPEGWallpapersQuality {
	Write-Output "Setting Default JPEG Wallpapers Quality ..."
	Remove-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name JPEGImportQuality -Force -ErrorAction Ignore
}

# Start Task Manager in the expanded mode
Function ExpandedTaskManagerWindow {
	Write-Output "Setting Expanded Task Manager Window ..."
	$Taskmgr = Get-Process -Name Taskmgr -ErrorAction Ignore

	Start-Sleep -Seconds 1

	if ($Taskmgr)
	{
		$Taskmgr.CloseMainWindow()
	}
	Start-Process -FilePath Taskmgr.exe -PassThru

	Start-Sleep -Seconds 3

	do
	{
		Start-Sleep -Milliseconds 100
		$Preferences = Get-ItemPropertyValue -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\TaskManager -Name Preferences
	}
	until ($Preferences)

	Stop-Process -Name Taskmgr -ErrorAction Ignore

	$Preferences[28] = 0
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\TaskManager -Name Preferences -PropertyType Binary -Value $Preferences -Force
}

# Start Task Manager in the compact mode
Function CompactTaskManagerWindow {
	Write-Output "Setting Compact Task Manager Window ..."
	$Taskmgr = Get-Process -Name Taskmgr -ErrorAction Ignore

	Start-Sleep -Seconds 1

	if ($Taskmgr)
	{
		$Taskmgr.CloseMainWindow()
	}
	Start-Process -FilePath Taskmgr.exe -PassThru

	Start-Sleep -Seconds 3

	do
	{
		Start-Sleep -Milliseconds 100
		$Preferences = Get-ItemPropertyValue -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\TaskManager -Name Preferences
	}
	until ($Preferences)

	Stop-Process -Name Taskmgr -ErrorAction Ignore
	$Preferences[28] = 1
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\TaskManager -Name Preferences -PropertyType Binary -Value $Preferences -Force
}

# Notify me when a restart is required to finish updating
Function ShowRestartNotification {
	Write-Output "Show Restart Notification ..."
	New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings -Name RestartNotificationsAllowed2 -PropertyType DWord -Value 1 -Force
}

# Do not notify me when a restart is required to finish updating
Function HideRestartNotification {
	Write-Output "Hide Restart Notification ..."
	New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings -Name RestartNotificationsAllowed2 -PropertyType DWord -Value 0 -Force
}

# Do not add the "- Shortcut" suffix to the file name of created shortcuts
Function DisableShortcutsSuffix {
	Write-Output "Disable Shortcuts Suffix ..."
	if (-not (Test-Path -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\NamingTemplates))
	{
		New-Item -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\NamingTemplates -Force
	}
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\NamingTemplates -Name ShortcutNameTemplate -PropertyType String -Value "%s.lnk" -Force
}

# Add the "- Shortcut" suffix to the file name of created shortcuts
Function EnableShortcutsSuffix {
	Write-Output "Enable Shortcuts Suffix ..."
	Remove-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\NamingTemplates -Name ShortcutNameTemplate -Force -ErrorAction Ignore
}

# Use the Print screen button to open screen snipping
Function EnablePrtScnSnippingTool {
	Write-Output "Enable PrtScn Snipping Tool ..."
	New-ItemProperty -Path "HKCU:\Control Panel\Keyboard" -Name PrintScreenKeyForSnippingEnabled -PropertyType DWord -Value 1 -Force
}

# Do not use the Print screen button to open screen snipping
Function DisablePrtScnSnippingTool {
	Write-Output "Disable PrtScn Snipping Tool ..."
	New-ItemProperty -Path "HKCU:\Control Panel\Keyboard" -Name PrintScreenKeyForSnippingEnabled -PropertyType DWord -Value 0 -Force
}

# Do not use a different input method for each app window
Function DisableAppsLanguageSwitch {
	Write-Output "Disable Apps Language Switch ..."
	Set-WinLanguageBarOption
}

# Let me use a different input method for each app window
Function EnableAppsLanguageSwitch {
	Write-Output "Enable Apps Language Switch ..."
	Set-WinLanguageBarOption -UseLegacySwitchMode
}

# When I grab a windows's title bar and shake it, don't minimize all other windows
Function DisableAeroShaking {
	Write-Output "Disable Aero Shaking ..."
	New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name DisallowShaking -PropertyType DWord -Value 1 -Force
}

# When I grab a windows's title bar and shake it, minimize all other windows
Function EnableAeroShaking {
	Write-Output "Enable Aero Shaking ..."
	New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name DisallowShaking -PropertyType DWord -Value 0 -Force
}

#endregion UI & Personalization

#region OneDrive

# Uninstall OneDrive
Function UninstallOneDrive {
	Write-Output "Uninstall OneDrive ..."
	If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive")) {
		New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive" | Out-Null
	}
	Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive" -Name "DisableFileSyncNGSC" -Type DWord -Value 1

	Write-Output "Uninstalling OneDrive..."
	Stop-Process -Name "OneDrive" -ErrorAction SilentlyContinue
	Start-Sleep -s 2
	$onedrive = "$env:SYSTEMROOT\SysWOW64\OneDriveSetup.exe"
	If (!(Test-Path $onedrive)) {
		$onedrive = "$env:SYSTEMROOT\System32\OneDriveSetup.exe"
	}
	Start-Process $onedrive "/uninstall" -NoNewWindow -Wait
	Start-Sleep -s 2
	Stop-Process -Name "explorer" -ErrorAction SilentlyContinue
	Start-Sleep -s 2
	Remove-Item -Path "$env:USERPROFILE\OneDrive" -Force -Recurse -ErrorAction SilentlyContinue
	Remove-Item -Path "$env:LOCALAPPDATA\Microsoft\OneDrive" -Force -Recurse -ErrorAction SilentlyContinue
	Remove-Item -Path "$env:PROGRAMDATA\Microsoft OneDrive" -Force -Recurse -ErrorAction SilentlyContinue
	Remove-Item -Path "$env:SYSTEMDRIVE\OneDriveTemp" -Force -Recurse -ErrorAction SilentlyContinue
	If (!(Test-Path "HKCR:")) {
		New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT | Out-Null
	}
	Remove-Item -Path "HKCR:\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" -Recurse -ErrorAction SilentlyContinue
	Remove-Item -Path "HKCR:\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" -Recurse -ErrorAction SilentlyContinue
}

# Install OneDrive
Function InstallOneDrive {
	Write-Output "Install OneDrive ..."
	Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive" -Name "DisableFileSyncNGSC" -ErrorAction SilentlyContinue
	& "$env:SystemRoot\SysWOW64\OneDriveSetup.exe"
}

#endregion OneDrive

#region System

# Turn on Storage Sense
Function EnableStorageSense {
	Write-Output "Enable Storage Sense ..."
	if (-not (Test-Path -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy))
	{
		New-Item -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -ItemType Directory -Force
	}
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 01 -PropertyType DWord -Value 1 -Force
}

# Turn off Storage Sense
Function DisableStorageSense {
	Write-Output "Disable Storage Sense ..."
	if (-not (Test-Path -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy))
	{
		New-Item -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -ItemType Directory -Force
	}
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 01 -PropertyType DWord -Value 0 -Force
}

# Turn on automatic cleaning up temporary system and app files
Function EnableStorageSenseTempFiles {
	Write-Output "Enable Storage Sense Temp Files ..."
	if ((Get-ItemPropertyValue -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 01) -eq "1")
	{
		New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 04 -PropertyType DWord -Value 1 -Force
	}	
}

# Turn off automatic cleaning up temporary system and app files
Function DisableStorageSenseTempFiles {
	Write-Output "Disable Storage Sense Temp Files ..."
	if ((Get-ItemPropertyValue -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 01) -eq "1")
	{
		New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 04 -PropertyType DWord -Value 0 -Force
	}
}

# Run Storage Sense every month
Function MonthStorageSenseFrequency {
	Write-Output "Setting Month Storage Sense Frequency ..."
	if ((Get-ItemPropertyValue -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 01) -eq "1")
	{
		New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 2048 -PropertyType DWord -Value 30 -Force
	}
}

# Run Storage Sense during low free disk space
Function DefaultStorageSenseFrequency {
	Write-Output "Setting Default Storage Sense Frequency ..."
	if ((Get-ItemPropertyValue -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 01) -eq "1")
	{
		New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy -Name 2048 -PropertyType DWord -Value 0 -Force
	}
}

# Disable hibernation
Function DisableHibernation {
	Write-Output "Disable Hibernation ..."
	POWERCFG /HIBERNATE OFF
}

# Enable hibernation
Function EnableHibernation {
	Write-Output "Enable Hibernation ..."
	POWERCFG /HIBERNATE ON
}

# Disable the Windows 260 character path limit
Function DisableWin32LongPathLimit {
	Write-Output "Disable Win32 Long Path Limit ..."
	New-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem -Name LongPathsEnabled -PropertyType DWord -Value 1 -Force
}

# Enable the Windows 260 character path limit
Function EnableWin32LongPathLimit {
	Write-Output "Enable Win32 Long Path Limit ..."
	New-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem -Name LongPathsEnabled -PropertyType DWord -Value 0 -Force
}

# Display the Stop error information on the BSoD
Function EnableBSoDStopError {
	Write-Output "Enable BSoD Stop Error ..."
	New-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl -Name DisplayParameters -PropertyType DWord -Value 1 -Force
}

# Do not display the Stop error information on the BSoD
Function DisableBSoDStopError {
	Write-Output "Disable BSoD Stop Error ..."
	New-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl -Name DisplayParameters -PropertyType DWord -Value 0 -Force
}

# Never notify when apps try to make changes to my computer
Function NeverAdminApprovalMode {
	Write-Output "Setting Never Admin Approval Mode ..."
	New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name ConsentPromptBehaviorAdmin -PropertyType DWord -Value 0 -Force
}

# Notify me only when apps try to make changes to my computer
Function DefaultAdminApprovalMode {
	Write-Output "Setting Default Admin Approval Mode ..."
	New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name ConsentPromptBehaviorAdmin -PropertyType DWord -Value 5 -Force
}

# Turn on access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled
Function EnableMappedDrivesAppElevatedAccess {
	Write-Output "Enable Mapped Drives App Elevated Access ..."
	New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLinkedConnections -PropertyType DWord -Value 1 -Force
}

# Turn off access to mapped drives from app running with elevated permissions with Admin Approval Mode enabled
Function DisableMappedDrivesAppElevatedAccess {
	Write-Output "Disable Mapped Drives App Elevated Access ..."
	Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLinkedConnections -Force -ErrorAction Ignore
}

# Turn off Delivery Optimization
Function DisableDeliveryOptimization {
	Write-Output "Disable Delivery Optimization ..."
	New-ItemProperty -Path Registry::HKEY_USERS\S-1-5-20\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Settings -Name DownloadMode -PropertyType DWord -Value 0 -Force
	Delete-DeliveryOptimizationCache -Force
}

# Turn on Delivery Optimization
Function EnableDeliveryOptimization {
	Write-Output "Enable Delivery Optimization ..."
	New-ItemProperty -Path Registry::HKEY_USERS\S-1-5-20\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Settings -Name DownloadMode -PropertyType DWord -Value 1 -Force
}

# Always wait for the network at computer startup and logon for workgroup networks
Function EnableWaitNetworkStartup {
	Write-Output "Enable Wait Network Startup ..."
	if ((Get-CimInstance -ClassName CIM_ComputerSystem).PartOfDomain -eq $true)
	{
		if (-not (Test-Path -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\Winlogon"))
		{
			New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\Winlogon" -Force
		}
		New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name SyncForegroundPolicy -PropertyType DWord -Value 1 -Force
	}
}

# Never wait for the network at computer startup and logon for workgroup networks
Function DisableWaitNetworkStartup {
	Write-Output "Disable Wait Network Startup ..."
	if ((Get-CimInstance -ClassName CIM_ComputerSystem).PartOfDomain -eq $true)
	{
		Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name SyncForegroundPolicy -Force -ErrorAction Ignore
	}
}

# Do not let Windows manage my default printer
Function DisableWindowsManageDefaultPrinter {
	Write-Output "Disable Windows Manage Default Printer ..."
	New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows" -Name LegacyDefaultPrinterMode -PropertyType DWord -Value 1 -Force
}

# Let Windows manage my default printer
Function EnableWindowsManageDefaultPrinter {
	Write-Output "Enable Windows Manage Default Printer ..."
	New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows" -Name LegacyDefaultPrinterMode -PropertyType DWord -Value 0 -Force
}

# Receive updates for other Microsoft products
Function EnableUpdateMicrosoftProducts {
	Write-Output "Enable Update Microsoft Products ..."
	(New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "")
}

# Do not receive updates for other Microsoft products
Function DisableUpdateMicrosoftProducts {
	Write-Output "Disable Update Microsoft Products ..."
	if ((New-Object -ComObject Microsoft.Update.ServiceManager).Services | Where-Object -FilterScript {$_.ServiceID -eq "7971f918-a847-4430-9279-4a52d1efe18d"})
	{
		(New-Object -ComObject Microsoft.Update.ServiceManager).RemoveService("7971f918-a847-4430-9279-4a52d1efe18d")
	}
}

# Set power plan on "High performance"
Function HighPowerPlan {
	Write-Output "Setting High Power Plan ..."
	POWERCFG /SETACTIVE SCHEME_MIN
}

# Set power plan on "Balanced"
Function BalancedPowerPlan {
	Write-Output "Setting Balanced Power Plan ..."
	POWERCFG /SETACTIVE SCHEME_BALANCED
}

# Use the latest installed .NET runtime for all apps
Function EnableLatestInstalledNET {
	Write-Output "Enable Latest Installed .NET ..."
	New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\.NETFramework -Name OnlyUseLatestCLR -PropertyType DWord -Value 1 -Force
	New-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework -Name OnlyUseLatestCLR -PropertyType DWord -Value 1 -Force
}

# Do not use the latest installed .NET runtime for all apps
Function DisableLatestInstalledNET {
	Write-Output "Disable Latest Installed .NET ..."
	Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\.NETFramework -Name OnlyUseLatestCLR -Force -ErrorAction Ignore
	Remove-ItemProperty -Path HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework -Name OnlyUseLatestCLR -Force -ErrorAction Ignore
}

# Do not allow the computer to turn off the network adapters to save power
Function DisableNetworkAdaptersSavePower {
	Write-Output "Disable Network Adapters Save Power ..."
	$Adapters = Get-NetAdapter -Physical | Get-NetAdapterPowerManagement | Where-Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"}
	foreach ($Adapter in $Adapters)
	{
		$Adapter.AllowComputerToTurnOffDevice = "Disabled"
		$Adapter | Set-NetAdapterPowerManagement
	}
}

# Allow the computer to turn off the network adapters to save power
Function EnableNetworkAdaptersSavePower {
	Write-Output "Enable Network Adapters Save Power ..."
	$Adapters = Get-NetAdapter -Physical | Get-NetAdapterPowerManagement | Where-Object -FilterScript {$_.AllowComputerToTurnOffDevice -ne "Unsupported"}
	foreach ($Adapter in $Adapters)
	{
		$Adapter.AllowComputerToTurnOffDevice = "Enabled"
		$Adapter | Set-NetAdapterPowerManagement
	}
}

# Override for default input method: English
Function EnglishInputMethod {
	Write-Output "Setting English Input Method  ..."
	Set-WinDefaultInputMethodOverride -InputTip "0409:00000409"
}

# Override for default input method: use language list
Function DefaultInputMethod {
	Write-Output "Setting Default Input Method  ..."
	Remove-ItemProperty -Path "HKCU:\Control Panel\International\User Profile" -Name InputMethodOverride -Force -ErrorAction Ignore
}

# Save screenshots by pressing Win+PrtScr on the Desktop
Function DesktopWinPrtScrFolder {
	Write-Output "Setting Desktop Win+PrtScr Folder ..."
	$DesktopFolder = Get-ItemPropertyValue -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name Desktop
	New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{B7BEDE81-DF94-4682-A7D8-57A52620B86F}" -Type ExpandString -Value $DesktopFolder -Force
}

# Save screenshots by pressing Win+PrtScr in the Pictures folder
Function DefaultWinPrtScrFolder {
	Write-Output "Setting Default Win+PrtScr Folder ..."
	Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "{B7BEDE81-DF94-4682-A7D8-57A52620B86F}" -Force -ErrorAction Ignore
}

# Run troubleshooter automatically, then notify me
Function AutomaticallyRecommendedTroubleshooting {
	Write-Output "Setting Automatically Recommended Troubleshooting ..."
	if (-not (Test-Path -Path HKLM:\SOFTWARE\Microsoft\WindowsMitigation))
	{
		New-Item -Path HKLM:\SOFTWARE\Microsoft\WindowsMitigation -Force
	}
	New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WindowsMitigation -Name UserPreference -PropertyType DWord -Value 3 -Force

	# Set the OS level of diagnostic data gathering to "Optional diagnostic data"
	New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 3 -Force
	New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 3 -Force

	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Name ShowedToastAtLevel -PropertyType DWord -Value 3 -Force

	# Turn on Windows Error Reporting
	Get-ScheduledTask -TaskName QueueReporting | Enable-ScheduledTask
	Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore

	Get-Service -Name WerSvc | Set-Service -StartupType Manual
	Get-Service -Name WerSvc | Start-Service
}

# Ask me before running troubleshooter
Function DefaultRecommendedTroubleshooting {
	Write-Output "Setting Default Recommended Troubleshooting ..."
	if (-not (Test-Path -Path HKLM:\SOFTWARE\Microsoft\WindowsMitigation))
	{
		New-Item -Path HKLM:\SOFTWARE\Microsoft\WindowsMitigation -Force
	}
	New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WindowsMitigation -Name UserPreference -PropertyType DWord -Value 2 -Force

	# Set the OS level of diagnostic data gathering to "Optional diagnostic data"
	New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name AllowTelemetry -PropertyType DWord -Value 3 -Force
	New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection -Name MaxTelemetryAllowed -PropertyType DWord -Value 3 -Force

	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack -Name ShowedToastAtLevel -PropertyType DWord -Value 3 -Force

	# Turn on Windows Error Reporting
	Get-ScheduledTask -TaskName QueueReporting | Enable-ScheduledTask
	Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\Windows Error Reporting" -Name Disabled -Force -ErrorAction Ignore

	Get-Service -Name WerSvc | Set-Service -StartupType Manual
	Get-Service -Name WerSvc | Start-Service
}

# Launch folder windows in a separate process
Function EnableFoldersLaunchSeparateProcess {
	Write-Output "Enable Folders Launch Separate Process ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name SeparateProcess -PropertyType DWord -Value 1 -Force
}

# Do not launch folder windows in a separate process
Function DisableFoldersLaunchSeparateProcess {
	Write-Output "Disable Folders Launch Separate Process ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name SeparateProcess -PropertyType DWord -Value 0 -Force
}

# Disable and delete reserved storage after the next update installation
Function DisableReservedStorage {
	Write-Output "Disable Reserved Storage ..."
	try
	{
		Set-WindowsReservedStorageState -State Disabled
	}
	catch [System.Runtime.InteropServices.COMException]
	{
		Write-Error -Message ($Localization.ReservedStorageIsInUse -f $MyInvocation.Line) -ErrorAction SilentlyContinue
	}
}

# Enable reserved storage after the next update installation
Function EnableReservedStorage {
	Write-Output "Enable Reserved Storage ..."
	Set-WindowsReservedStorageState -State Enabled
}

# Disable help lookup via F1
Function DisableF1HelpPage {
	Write-Output "Disable F1 Help Page ..."
	if (-not (Test-Path -Path "HKCU:\SOFTWARE\Classes\Typelib\{8cec5860-07a1-11d9-b15e-000d56bfe6ee}\1.0\0\win64"))
	{
		New-Item -Path "HKCU:\SOFTWARE\Classes\Typelib\{8cec5860-07a1-11d9-b15e-000d56bfe6ee}\1.0\0\win64" -Force
	}
	New-ItemProperty -Path "HKCU:\SOFTWARE\Classes\Typelib\{8cec5860-07a1-11d9-b15e-000d56bfe6ee}\1.0\0\win64" -Name "(default)" -PropertyType String -Value "" -Force
}

# Enable help lookup via F1
Function EnableF1HelpPage {
	Write-Output "Enable F1 Help Page ..."
	Remove-Item -Path "HKCU:\SOFTWARE\Classes\Typelib\{8cec5860-07a1-11d9-b15e-000d56bfe6ee}" -Recurse -Force -ErrorAction Ignore
}

# Enable Num Lock at startup
Function EnableNumLock {
	Write-Output "Enable NumLock at startup ..."
	New-ItemProperty -Path "Registry::HKEY_USERS\.DEFAULT\Control Panel\Keyboard" -Name InitialKeyboardIndicators -PropertyType String -Value 2147483650 -Force
}

# Disable Num Lock at startup
Function DisableNumLock {
	Write-Output "Disable NumLock at startup ..."
	New-ItemProperty -Path "Registry::HKEY_USERS\.DEFAULT\Control Panel\Keyboard" -Name InitialKeyboardIndicators -PropertyType String -Value 2147483648 -Force
}

# Disable Caps Lock
Function DisableCapsLock {
	Write-Output "Disable Caps Lock ..."
	New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Keyboard Layout" -Name "Scancode Map" -PropertyType Binary -Value ([byte[]](0,0,0,0,0,0,0,0,2,0,0,0,0,0,58,0,0,0,0,0)) -Force
}

# Enable Caps Lock
Function EnableCapsLock {
	Write-Output "Enable Caps Lock ..."
	Remove-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Keyboard Layout" -Name "Scancode Map" -Force -ErrorAction Ignore
}

# Turn off pressing the Shift key 5 times to turn Sticky keys
Function DisableStickyShift {
	Write-Output "Disable Sticky Shift ..."
	New-ItemProperty -Path "HKCU:\Control Panel\Accessibility\StickyKeys" -Name Flags -PropertyType String -Value 506 -Force
}

# Turn on pressing the Shift key 5 times to turn Sticky keys
Function EnableStickyShift {
	Write-Output "Enable Sticky Shift ..."
	New-ItemProperty -Path "HKCU:\Control Panel\Accessibility\StickyKeys" -Name Flags -PropertyType String -Value 510 -Force
}

# Don't use AutoPlay for all media and devices
Function DisableAutoplay {
	Write-Output "Disable Autoplay ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers -Name DisableAutoplay -PropertyType DWord -Value 1 -Force
}

# Use AutoPlay for all media and devices
Function EnableAutoplay {
	Write-Output "Enable Autoplay ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers -Name DisableAutoplay -PropertyType DWord -Value 0 -Force
}

# Disable thumbnail cache removal
Function DisableThumbnailCacheRemoval {
	Write-Output "Disable Thumbnail Cache Removal ..."
	New-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Thumbnail Cache" -Name Autorun -PropertyType DWord -Value 0 -Force
}

# Enable thumbnail cache removal
Function EnableThumbnailCacheRemoval {
	Write-Output "Enable Thumbnail Cache Removal ..."
	New-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Thumbnail Cache" -Name Autorun -PropertyType DWord -Value 3 -Force
}

# Automatically saving my restartable apps and restart them when I sign back in
Function EnableSaveRestartableApps {
	Write-Output "Enable Save Restartable Apps ..."
	New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name RestartApps -Value 1 -Force
}

# Turn off automatically saving my restartable apps and restart them when I sign back in
Function DisableSaveRestartableApps {
	Write-Output "Disable Save Restartable Apps ..."
	New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name RestartApps -Value 0 -Force
}

# Enable "Network Discovery" and "File and Printers Sharing" for workgroup networks
Function EnableNetworkDiscovery {
	Write-Output "Enable Network Discovery ..."
	$FirewallRules = @(
		# File and printer sharing		
		"@FirewallAPI.dll,-32752",

		# Network discovery
		"@FirewallAPI.dll,-28502"
	)
	if ((Get-CimInstance -ClassName CIM_ComputerSystem).PartOfDomain -eq $false)
	{
		Set-NetFirewallRule -Group $FirewallRules -Profile Private -Enabled True
		Set-NetFirewallRule -Profile Public, Private -Name FPS-SMB-In-TCP -Enabled True
		Set-NetConnectionProfile -NetworkCategory Private
	}
}

# Disable "Network Discovery" and "File and Printers Sharing" for workgroup networks
Function DisableNetworkDiscovery {
	Write-Output "Disable Network Discovery ..."
	$FirewallRules = @(
		# File and printer sharing		
		"@FirewallAPI.dll,-32752",

		# Network discovery
		"@FirewallAPI.dll,-28502"
	)
	if ((Get-CimInstance -ClassName CIM_ComputerSystem).PartOfDomain -eq $false)
	{
		Set-NetFirewallRule -Group $FirewallRules -Profile Private -Enabled False
	}
}

# Automatically adjust active hours for me based on daily usage
Function AutomaticallyActiveHours {
	Write-Output "Setting Automatically Active Hours ..."
	New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings -Name SmartActiveHoursState -PropertyType DWord -Value 1 -Force
}

# Manually adjust active hours for me based on daily usage
Function ManuallyActiveHours {
	Write-Output "Setting Manually Active Hours ..."
	New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings -Name SmartActiveHoursState -PropertyType DWord -Value 0 -Force
}

# Restart as soon as possible to finish updating
Function EnableDeviceRestartAfterUpdate {
	Write-Output "Enable Device Restart After Update ..."
	New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings -Name IsExpedited -PropertyType DWord -Value 1 -Force
}

# Don't restart as soon as possible to finish updating
Function DisableDeviceRestartAfterUpdate {
	Write-Output "Disable Device Restart After Update ..."
	New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings -Name IsExpedited -PropertyType DWord -Value 0 -Force
}

# Set Windows Terminal Preview as default terminal app to host the user interface for command-line applications
Function WindowsTerminalDefaultTerminalApp {
	Write-Output "Setting Windows Terminal Default Terminal App ..."
	if (-not (Test-Path -Path HKCU:\Console\%%Startup))
	{
		New-Item -Path HKCU:\Console\%%Startup -Force
	}
	New-ItemProperty -Path HKCU:\Console\%%Startup -Name DelegationConsole -PropertyType String -Value "{06EC847C-C0A5-46B8-92CB-7C92F6E35CD5}" -Force
	New-ItemProperty -Path HKCU:\Console\%%Startup -Name DelegationTerminal -PropertyType String -Value "{86633F1F-6454-40EC-89CE-DA4EBA977EE2}" -Force
}

# Set Windows Console Host as default terminal app to host the user interface for command-line applications
Function ConsoleHostDefaultTerminalApp {
	Write-Output "Setting Console Host Default Terminal App ..."
	Remove-Item -Path HKCU:\Console\%%Startup -Force -ErrorAction Ignore
}

#endregion System

#region Start menu

# Hide recently added apps in the Start menu
Function HideRecentlyAddedApps {
	Write-Output "Hide Recently Added Apps ..."
	if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer))
	{
		New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Force
	}
	New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -PropertyType DWord -Value 1 -Force
}

# Show recently added apps in the Start menu
Function ShowRecentlyAddedApps {
	Write-Output "Show Recently Added Apps ..."
	Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name HideRecentlyAddedApps -Force -ErrorAction Ignore
}

# Run the Windows PowerShell shortcut from the Start menu as Administrator
Function ElevatedRunPowerShellShortcut {
	Write-Output "Setting Elevated Run PowerShell Shortcut ..."
	[byte[]]$bytes = Get-Content -Path "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Windows PowerShell\Windows PowerShell.lnk" -Encoding Byte -Raw
	$bytes[0x15] = $bytes[0x15] -bor 0x20
	Set-Content -Path "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Windows PowerShell\Windows PowerShell.lnk" -Value $bytes -Encoding Byte -Force
}

# Run the Windows PowerShell shortcut from the Start menu as user
Function NonElevatedRunPowerShellShortcut {
	Write-Output "Setting NonElevated Run PowerShell Shortcut ..."
	[byte[]]$bytes = Get-Content -Path "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Windows PowerShell\Windows PowerShell.lnk" -Encoding Byte -Raw
	$bytes[0x15] = $bytes[0x15] -bxor 0x20
	Set-Content -Path "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Windows PowerShell\Windows PowerShell.lnk" -Value $bytes -Encoding Byte -Force
}

#endregion Start menu

#region UWP apps

# Disable Cortana autostarting
Function DisableCortanaAutostart {
	Write-Output "Disable Cortana Autostart ..."
	if (Get-AppxPackage -Name Microsoft.549981C3F5F10)
	{
		if (-not (Test-Path -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId"))
		{
			New-Item -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId" -Force
		}
		New-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId" -Name State -PropertyType DWord -Value 1 -Force
	}
}

# Enable Cortana autostarting
Function EnableCortanaAutostart {
	Write-Output "Enable Cortana Autostart ..."
	if (Get-AppxPackage -Name Microsoft.549981C3F5F10)
	{
		if (-not (Test-Path -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId"))
		{
			New-Item -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId" -Force
		}
		New-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\Microsoft.549981C3F5F10_8wekyb3d8bbwe\CortanaStartupId" -Name State -PropertyType DWord -Value 2 -Force
	}
}

# Disable Teams autostarting
Function DisableTeamsAutostart {
	Write-Output "Disable Teams Autostart ..."
	if (Get-AppxPackage -Name MicrosoftTeams)
	{
		if (-not (Test-Path -Path "HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\MicrosoftTeams_8wekyb3d8bbwe\TeamsStartupTask"))
		{
			New-Item -Path "HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\MicrosoftTeams_8wekyb3d8bbwe\TeamsStartupTask" -Force
		}
		New-ItemProperty -Path "HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\MicrosoftTeams_8wekyb3d8bbwe\TeamsStartupTask" -Name State -PropertyType DWord -Value 1 -Force
	}
}

# Enable Teams autostarting
Function EnableTeamsAutostart {
	Write-Output "Enable Teams Autostart ..."
	if (Get-AppxPackage -Name MicrosoftTeams)
	{
		if (-not (Test-Path -Path "HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\MicrosoftTeams_8wekyb3d8bbwe\TeamsStartupTask"))
		{
			New-Item -Path "HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\MicrosoftTeams_8wekyb3d8bbwe\TeamsStartupTask" -Force
		}
		New-ItemProperty -Path "HKCU:\Software\Classes\Local 	Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\MicrosoftTeams_8wekyb3d8bbwe\TeamsStartupTask" -Name State -PropertyType DWord -Value 2 -Force
	}
}

#endregion UWP apps

#region Gaming

# Disable Xbox Game Bar tips
Function DisableXboxGameTips {
	Write-Output "Disable Xbox Game Tips ..."
	if ((Get-AppxPackage -Name Microsoft.XboxGamingOverlay) -or (Get-AppxPackage -Name Microsoft.GamingApp))
	{
		New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\GameBar -Name ShowStartupPanel -PropertyType DWord -Value 0 -Force
	}
}

# Enable Xbox Game Bar tips
Function EnableXboxGameTips {
	Write-Output "Enable Xbox Game Tips ..."
	if ((Get-AppxPackage -Name Microsoft.XboxGamingOverlay) -or (Get-AppxPackage -Name Microsoft.GamingApp))
	{
		New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\GameBar -Name ShowStartupPanel -PropertyType DWord -Value 1 -Force
	}
}

# Enable hardware-accelerated GPU scheduling
Function EnableGPUScheduling {
	Write-Output "Enable GPU Scheduling ..."
	if (Get-CimInstance -ClassName CIM_VideoController | Where-Object -FilterScript {($_.AdapterDACType -ne "Internal") -and ($null -ne $_.AdapterDACType)})
	{
		# Determining whether an OS is not installed on a virtual machine
		if ((Get-CimInstance -ClassName CIM_ComputerSystem).Model -notmatch "Virtual")
		{
			# Checking whether a WDDM verion is 2.7 or higher
			$WddmVersion_Min = Get-ItemPropertyValue -Path HKLM:\SYSTEM\CurrentControlSet\Control\GraphicsDrivers\FeatureSetUsage -Name WddmVersion_Min
			if ($WddmVersion_Min -ge 2700)
			{
				New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\GraphicsDrivers" -Name HwSchMode -PropertyType DWord -Value 2 -Force
			}
		}
	}
}

# Disable hardware-accelerated GPU scheduling
Function DisableGPUScheduling {
	Write-Output "Disable GPU Scheduling ..."
	New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\GraphicsDrivers" -Name HwSchMode -PropertyType DWord -Value 1 -Force
}

#endregion Gaming

#region Microsoft Defender & Security

# Enable Microsoft Defender Exploit Guard network protection
Function EnableNetworkProtection {
	Write-Output "Enable Network Protection ..."
	if ((Get-MpComputerStatus).AntivirusEnabled -eq $true)
	{
		Set-MpPreference -EnableNetworkProtection Enabled
	}
}

# Disable Microsoft Defender Exploit Guard network protection
Function DisableNetworkProtection {
	Write-Output "Disable Network Protection ..."
	if ((Get-MpComputerStatus).AntivirusEnabled -eq $true)
	{
		Set-MpPreference -EnableNetworkProtection Disabled
	}
}

# Enable detection for potentially unwanted applications and block them
Function EnablePUAppsDetection {
	Write-Output "Enable PU Apps Detection ..."
	if ((Get-MpComputerStatus).AntivirusEnabled -eq $true)
	{
		Set-MpPreference -PUAProtection Enabled
	}
}

# Disable detection for potentially unwanted applications and block them
Function DisablePUAppsDetection {
	Write-Output "Disable PU Apps Detection ..."
	if ((Get-MpComputerStatus).AntivirusEnabled -eq $true)
	{
		Set-MpPreference -PUAProtection Disabled
	}
}

# Enable sandboxing for Microsoft Defender
Function EnableDefenderSandbox {
	Write-Output "Enable Defender Sandbox ..."
	if ((Get-MpComputerStatus).AntivirusEnabled -eq $true)
	{
		setx /M MP_FORCE_USE_SANDBOX 1
	}
}

# Disable sandboxing for Microsoft Defender
Function DisableDefenderSandbox {
	Write-Output "Disable Defender Sandbox ..."
	if ((Get-MpComputerStatus).AntivirusEnabled -eq $true)
	{
		setx /M MP_FORCE_USE_SANDBOX 0
	}
}

# Enable events auditing generated when a process is created (starts)
Function EnableAuditProcess {
	Write-Output "Enable Audit Process ..."
	auditpol /set /subcategory:"{0CCE922B-69AE-11D9-BED3-505054503030}" /success:enable /failure:enable
}

# Disable events auditing generated when a process is created (starts)
Function DisableAuditProcess {
	Write-Output "Disable Audit Process ..."
	auditpol /set /subcategory:"{0CCE922B-69AE-11D9-BED3-505054503030}" /success:disable /failure:disable
}

# Include command line in process creation events
Function EnableCommandLineProcessAudit {
	Write-Output "Enable Command Line Process Audit ..."
	# Enable events auditing generated when a process is created (starts)
	auditpol /set /subcategory:"{0CCE922B-69AE-11D9-BED3-505054503030}" /success:enable /failure:enable
	New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\Audit -Name ProcessCreationIncludeCmdLine_Enabled -PropertyType DWord -Value 1 -Force
}

# Do not include command line in process creation events
Function DisableCommandLineProcessAudit {
	Write-Output "Disable Command Line Process Audit ..."
	Remove-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\Audit -Name ProcessCreationIncludeCmdLine_Enabled -Force -ErrorAction Ignore
}

# Create the "Process Creation" Event Viewer сustom view to log the executed processes and their arguments
Function EnableEventViewerCustomView {
	Write-Output "Enable Event Viewer Custom View ..."
	# Enable events auditing generated when a process is created (starts)
	auditpol /set /subcategory:"{0CCE922B-69AE-11D9-BED3-505054503030}" /success:enable /failure:enable

	# Include command line in process creation events
	New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\Audit -Name ProcessCreationIncludeCmdLine_Enabled -PropertyType DWord -Value 1 -Force

	$XML = @"
<ViewerConfig>
	<QueryConfig>
		<QueryParams>
			<UserQuery />
		</QueryParams>
		<QueryNode>
			<Name>$($Localization.EventViewerCustomViewName)</Name>
			<Description>$($Localization.EventViewerCustomViewDescription)</Description>
			<QueryList>
				<Query Id="0" Path="Security">
					<Select Path="Security">*[System[(EventID=4688)]]</Select>
				</Query>
			</QueryList>
		</QueryNode>
	</QueryConfig>
</ViewerConfig>
"@

	if (-not (Test-Path -Path "$env:ProgramData\Microsoft\Event Viewer\Views"))
	{
		New-Item -Path "$env:ProgramData\Microsoft\Event Viewer\Views" -ItemType Directory -Force
	}

	# Save ProcessCreation.xml in the UTF-8 with BOM encoding
	Set-Content -Path "$env:ProgramData\Microsoft\Event Viewer\Views\ProcessCreation.xml" -Value $XML -Encoding UTF8 -Force
}

# Remove the "Process Creation" Event Viewer custom view
Function DisableEventViewerCustomView {
	Write-Output "Disable Event Viewer Custom View ..."
	Remove-Item -Path "$env:ProgramData\Microsoft\Event Viewer\Views\ProcessCreation.xml" -Force -ErrorAction Ignore
}

# Enable logging for all Windows PowerShell modules
Function EnablePowerShellModulesLogging {
	Write-Output "Enable PowerShell Modules Logging ..."
	if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ModuleLogging\ModuleNames))
	{
		New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ModuleLogging\ModuleNames -Force
	}
	New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ModuleLogging -Name EnableModuleLogging -PropertyType DWord -Value 1 -Force
	New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ModuleLogging\ModuleNames -Name * -PropertyType String -Value * -Force
}

# Disable logging for all Windows PowerShell modules
Function DisablePowerShellModulesLogging {
	Write-Output "Disable PowerShell Modules Logging ..."
	Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ModuleLogging -Name EnableModuleLogging -Force -ErrorAction Ignore
	Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ModuleLogging\ModuleNames -Name * -Force -ErrorAction Ignore
}

# Enable logging for all PowerShell scripts input to the Windows PowerShell event log
Function EnablePowerShellScriptsLogging {
	Write-Output "Enable PowerShell Scripts Logging ..."
	if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging))
	{
		New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging -Force
	}
	New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging -Name EnableScriptBlockLogging -PropertyType DWord -Value 1 -Force
}

# Disable logging for all PowerShell scripts input to the Windows PowerShell event log
Function DisablePowerShellScriptsLogging {
	Write-Output "Disable PowerShell Scripts Logging ..."
	Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging -Name EnableScriptBlockLogging -Force -ErrorAction Ignore
}

# Disable apps and files checking within Microsoft Defender SmartScreen
Function DisableAppsSmartScreen {
	Write-Output "Disable Apps SmartScreen ..."
	New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer -Name SmartScreenEnabled -PropertyType String -Value Off -Force
}

# Enable apps and files checking within Microsoft Defender SmartScreen
Function EnableAppsSmartScreen {
	Write-Output "Enable Apps SmartScreen ..."
	New-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer -Name SmartScreenEnabled -PropertyType String -Value Warn -Force
}

# Microsoft Defender SmartScreen doesn't marks downloaded files from the Internet as unsafe
Function DisableSaveZoneInformation {
	Write-Output "Disable Save Zone Information ..."
	if (-not (Test-Path -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Attachments))
	{
		New-Item -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Attachments -Force
	}
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Attachments -Name SaveZoneInformation -PropertyType DWord -Value 1 -Force
}

# Microsoft Defender SmartScreen marks downloaded files from the Internet as unsafe
Function EnableSaveZoneInformation {
	Write-Output "Enable Save Zone Information ..."
	Remove-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Attachments -Name SaveZoneInformation -Force -ErrorAction Ignore
}

# Disable Windows Script Host
Function DisableWindowsScriptHost {
	Write-Output "Disable Windows Script Host ..."
	if (-not (Test-Path -Path "HKCU:\SOFTWARE\Microsoft\Windows Script Host\Settings"))
	{
		New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Force
	}
	New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name Enabled -PropertyType DWord -Value 0 -Force
}

# Enable Windows Script Host
Function EnableWindowsScriptHost {
	Write-Output "Enable Windows Script Host ..."
	Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name Enabled -Force -ErrorAction Ignore
}

# Disable Windows Sandbox
Function DisableWindowsSandbox {
	Write-Output "Disable Windows Sandbox ..."
	if (Get-WindowsEdition -Online | Where-Object -FilterScript {$_.Edition -eq "Professional" -or $_.Edition -like "Enterprise*"})
	{
		# Checking whether x86 virtualization is enabled in the firmware
		if ((Get-CimInstance -ClassName CIM_Processor).VirtualizationFirmwareEnabled -eq $true)
		{
			Disable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -Online -NoRestart
		}
		else
		{
			try
			{
				# Determining whether Hyper-V is enabled
				if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent -eq $true)
				{
					Disable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -Online -NoRestart
				}
			}
			catch [System.Exception]
			{
				Write-Error -Message $Localization.EnableHardwareVT -ErrorAction SilentlyContinue
			}
		}
	}
}

# Enable Windows Sandbox
Function EnableWindowsSandbox {
	Write-Output "Enable Windows Sandbox ..."
	if (Get-WindowsEdition -Online | Where-Object -FilterScript {$_.Edition -eq "Professional" -or $_.Edition -like "Enterprise*"})
	{
		# Checking whether x86 virtualization is enabled in the firmware
		if ((Get-CimInstance -ClassName CIM_Processor).VirtualizationFirmwareEnabled -eq $true)
		{
			Enable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -All -Online -NoRestart
		}
		else
		{
			try
			{
				# Determining whether Hyper-V is enabled
				if ((Get-CimInstance -ClassName CIM_ComputerSystem).HypervisorPresent -eq $true)
				{
					Enable-WindowsOptionalFeature -FeatureName Containers-DisposableClientVM -All -Online -NoRestart
				}
			}
			catch [System.Exception]
			{
				Write-Error -Message $Localization.EnableHardwareVT -ErrorAction SilentlyContinue
			}
		}
	}
}

#endregion Microsoft Defender & Security

#region Context menu

# Show the "Extract all" item in the Windows Installer (.msi) context menu
Function ShowMSIExtractContext {
	Write-Output "Show MSI Extract Context ..."
	if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\Msi.Package\shell\Extract\Command))
	{
		New-Item -Path Registry::HKEY_CLASSES_ROOT\Msi.Package\shell\Extract\Command -Force
	}
	$Value = "{0}" -f "msiexec.exe /a `"%1`" /qb TARGETDIR=`"%1 extracted`""
	New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\Msi.Package\shell\Extract\Command -Name "(default)" -PropertyType String -Value $Value -Force
	New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\Msi.Package\shell\Extract -Name MUIVerb -PropertyType String -Value "@shell32.dll,-37514" -Force
	New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\Msi.Package\shell\Extract -Name Icon -PropertyType String -Value "shell32.dll,-16817" -Force
}

# Hide the "Extract all" item from the Windows Installer (.msi) context menu
Function HideMSIExtractContext {
	Write-Output "Hide MSI Extract Context ..."
	Remove-Item -Path Registry::HKEY_CLASSES_ROOT\Msi.Package\shell\Extract -Recurse -Force -ErrorAction Ignore
}

# Show the "Install" item in the Cabinet (.cab) filenames extensions context menu
Function ShowCABInstallContext {
	Write-Output "Show CAB Install Context ..."
	if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\RunAs\Command))
	{
		New-Item -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\RunAs\Command -Force
	}
	$Value = "{0}" -f "cmd /c DISM.exe /Online /Add-Package /PackagePath:`"%1`" /NoRestart & pause"
	New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\RunAs\Command -Name "(default)" -PropertyType String -Value $Value -Force
	New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\RunAs -Name MUIVerb -PropertyType String -Value "@shell32.dll,-10210" -Force
	New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\RunAs -Name HasLUAShield -PropertyType String -Value "" -Force
}

# Hide the "Install" item from the Cabinet (.cab) filenames extensions context menu
Function HideCABInstallContext {
	Write-Output "Hide CAB Install Context ..."
	Remove-Item -Path Registry::HKEY_CLASSES_ROOT\CABFolder\Shell\RunAs -Recurse -Force -ErrorAction Ignore
}

# Show the "Run as different user" item in the .exe filename extensions context menu
Function ShowRunAsDifferentUserContext {
	Write-Output "Show Run As Different User Context ..."
	Remove-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\exefile\shell\runasuser -Name Extended -Force -ErrorAction Ignore
}

# Hide the "Run as different user" item from the .exe filename extensions context menu
Function HideRunAsDifferentUserContext {
	Write-Output "Hide Run As Different User Context ..."
	New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\exefile\shell\runasuser -Name Extended -PropertyType String -Value "" -Force
}

# Hide the "Cast to Device" item from the media files and folders context menu
Function HideCastToDeviceContext {
	Write-Output "Hide Cast To Device Context ..."
	if (-not (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked"))
	{
		New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force
	}
	New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -PropertyType String -Value "Play to menu" -Force
}

# Show the "Cast to Device" item in the media files and folders context menu
Function ShowCastToDeviceContext {
	Write-Output "Show Cast To Device Context ..."
	Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -Force -ErrorAction Ignore
}

# Hide the "Share" item from the context menu
Function HideShareContext {
	Write-Output "Hide Share Context ..."
	Remove-Item -Path "Registry::HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers\ModernSharing" -Recurse -Force -ErrorAction Ignore
}

# Show the "Share" item in the context menu
Function ShowShareContext {
	Write-Output "Show Share Context ..."
	if (-not (Test-Path -Path "Registry::HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers\ModernSharing"))
	{
		New-Item -Path "Registry::HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers\ModernSharing" -Force
	}
	New-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers\ModernSharing" -Name "(default)" -PropertyType String -Value "{e2bf9676-5f8f-435c-97eb-11607a5bedf7}" -Force		
}

# Hide the "Edit with Photos" item from the media files context men
Function HideEditWithPhotosContext {
	Write-Output "Hide Edit With Photos Context ..."
	if (Get-AppxPackage -Name Microsoft.Windows.Photos)
	{
		New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\AppX43hnxtbyyps62jhe9sqpdzxn1790zetc\Shell\ShellEdit -Name ProgrammaticAccessOnly -PropertyType String -Value "" -Force
	}
}

# Show the "Edit with Photos" item in the media files context menu
Function ShowEditWithPhotosContext {
	Write-Output "Show Edit With Photos Context ..."
	if (Get-AppxPackage -Name Microsoft.Windows.Photos)
	{
		Remove-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\AppX43hnxtbyyps62jhe9sqpdzxn1790zetc\Shell\ShellEdit -Name ProgrammaticAccessOnly -Force -ErrorAction Ignore
	}
}

# Hide the "Create a new video" item from the media files context menu
Function HideCreateANewVideoContext {
	Write-Output "Hide Create A New Video Context ..."
	if (Get-AppxPackage -Name Microsoft.Windows.Photos)
	{
		New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\AppX43hnxtbyyps62jhe9sqpdzxn1790zetc\Shell\ShellCreateVideo -Name ProgrammaticAccessOnly -PropertyType String -Value "" -Force
	}
}

# Show the "Create a new video" item in the media files context menu
Function ShowCreateANewVideoContext {
	Write-Output "Show Create A New Video Context ..."
	if (Get-AppxPackage -Name Microsoft.Windows.Photos)
	{
		Remove-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\AppX43hnxtbyyps62jhe9sqpdzxn1790zetc\Shell\ShellCreateVideo -Name ProgrammaticAccessOnly -Force -ErrorAction Ignore
	}
}

# Hide the "Print" item from the .bat and .cmd context menu
Function HidePrintCMDContext {
	Write-Output "Hide Print CMD Context ..."
	New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\batfile\shell\print -Name ProgrammaticAccessOnly -PropertyType String -Value "" -Force
	New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\cmdfile\shell\print -Name ProgrammaticAccessOnly -PropertyType String -Value "" -Force
}

# Show the "Print" item in the .bat and .cmd context menu
Function ShowPrintCMDContext {
	Write-Output "Show Print CMD Context ..."
	Remove-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\batfile\shell\print -Name ProgrammaticAccessOnly -Force -ErrorAction Ignore
	Remove-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\cmdfile\shell\print -Name ProgrammaticAccessOnly -Force -ErrorAction Ignore
}

# Hide the "Include in Library" item from the folders and drives context menu
Function HideIncludeInLibraryContext {
	Write-Output "Hide Include In Library Context ..."
	New-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\Folder\ShellEx\ContextMenuHandlers\Library Location" -Name "(default)" -PropertyType String -Value "-{3dad6c5d-2167-4cae-9914-f99e41c12cfa}" -Force
}


# Show the "Include in Library" item in the folders and drives context menu
Function ShowIncludeInLibraryContext {
	Write-Output "Show Include In Library Context ..."
	New-ItemProperty -Path "Registry::HKEY_CLASSES_ROOT\Folder\ShellEx\ContextMenuHandlers\Library Location" -Name "(default)" -PropertyType String -Value "{3dad6c5d-2167-4cae-9914-f99e41c12cfa}" -Force
}

# Hide the "Send to" item from the folders context menu
Function HideSendToContext {
	Write-Output "Hide Send To Context ..."
	New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers\SendTo -Name "(default)" -PropertyType String -Value "-{7BA4C740-9E81-11CF-99D3-00AA004AE837}" -Force
}

# Show the "Send to" item in the folders context menu
Function ShowSendToContext {
	Write-Output "Show Send To Context ..."
	New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers\SendTo -Name "(default)" -PropertyType String -Value "{7BA4C740-9E81-11CF-99D3-00AA004AE837}" -Force
}

# Hide the "Turn on BitLocker" item from the drives context menu
Function HideBitLockerContext {
	Write-Output "Hide BitLocker Context ..."
	if (Get-WindowsEdition -Online | Where-Object -FilterScript {($_.Edition -eq "Professional") -or ($_.Edition -like "Enterprise*")})
	{
		if ((Get-BitLockerVolume).ProtectionStatus -eq "Off")
		{
			New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\Drive\shell\encrypt-bde-elev -Name ProgrammaticAccessOnly -PropertyType String -Value "" -Force
		}
	}
}

# Show the "Turn on BitLocker" item in the drives context menu
Function ShowBitLockerContext {
	Write-Output "Show BitLocker Context ..."
	if (Get-WindowsEdition -Online | Where-Object -FilterScript {$_.Edition -eq "Professional" -or $_.Edition -like "Enterprise*"})
	{
		Remove-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\Drive\shell\encrypt-bde-elev -Name ProgrammaticAccessOnly -Force -ErrorAction Ignore
	}
}

# Hide the "Compressed (zipped) Folder" item from the "New" context menu
Function HideCompressedFolderNewContext {
	Write-Output "Hide Compressed Folder New Context ..."
	Remove-Item -Path Registry::HKEY_CLASSES_ROOT\.zip\CompressedFolder\ShellNew -Force -ErrorAction Ignore
}

# Show the "Compressed (zipped) Folder" item to the "New" context menu
Function ShowCompressedFolderNewContext {
	Write-Output "Show Compressed Folder New Context ..."
	if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\.zip\CompressedFolder\ShellNew))
	{
		New-Item -Path Registry::HKEY_CLASSES_ROOT\.zip\CompressedFolder\ShellNew -Force
	}
	New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\.zip\CompressedFolder\ShellNew -Name Data -PropertyType Binary -Value ([byte[]](80,75,5,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)) -Force
	New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\.zip\CompressedFolder\ShellNew -Name ItemName -PropertyType ExpandString -Value "@%SystemRoot%\system32\zipfldr.dll,-10194" -Force
}

# Enable the "Open", "Print", and "Edit" items if more than 15 files selected
Function EnableMultipleInvokeContext {
	Write-Output "Enable Multiple Invoke Context ..."
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer -Name MultipleInvokePromptMinimum -PropertyType DWord -Value 300 -Force
}

# Disable the "Open", "Print", and "Edit" items if more than 15 files selected
Function DisableMultipleInvokeContext {
	Write-Output "Disable Multiple Invoke Context ..."
	Remove-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer -Name MultipleInvokePromptMinimum -Force -ErrorAction Ignore
}

# Hide the "Look for an app in the Microsoft Store" item in the "Open with" dialog
Function HideUseStoreOpenWith {
	Write-Output "Hide Use Store Open With ..."
	if (-not (Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer))
	{
		New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Force
	}
	New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoUseStoreOpenWith -PropertyType DWord -Value 1 -Force
}

# Show the "Look for an app in the Microsoft Store" item in the "Open with" dialog
Function ShowUseStoreOpenWith {
	Write-Output "Show Use Store Open With ..."
	Remove-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer -Name NoUseStoreOpenWith -Force -ErrorAction Ignore
}

# Hide the "Open in Windows Terminal" menu option in the folders context menu
Function HideOpenWindowsTerminalContext {
	Write-Output "Hide Open Windows Terminal Context ..."
	if (Get-AppxPackage -Name Microsoft.WindowsTerminal)
	{
		if (-not (Test-Path -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked"))
		{
			New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Force
		}
		New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{9F156763-7844-4DC4-B2B1-901F640F5155}" -PropertyType String -Value "WindowsTerminal" -Force
	}
}

# Show the "Open in Windows Terminal" menu option in the folders context menu
Function ShowOpenWindowsTerminalContext {
	Write-Output "Show Open Windows Terminal Context ..."
	if (Get-AppxPackage -Name Microsoft.WindowsTerminal)
	{
		Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{9F156763-7844-4DC4-B2B1-901F640F5155}" -Force -ErrorAction Ignore
	}
}

# Hide the "Open in Windows Terminal (Admin)" item from the Desktop and folders context menu
Function HideOpenWindowsTerminalAdminContext {
	Write-Output "Hide Open Windows Terminal Context ..."
	$Items = @(
		"Registry::HKEY_CLASSES_ROOT\Directory\Background\shell\runas",
		"Registry::HKEY_CLASSES_ROOT\Directory\shell\runas"
	)
	Remove-Item -Path $Items -Recurse -Force -ErrorAction Ignore
}

# Show the "Open in Windows Terminal (Admin)" item in the Desktop and folders context menu
Function ShowOpenWindowsTerminalAdminContext {
	Write-Output "Show Open Windows Terminal Context ..."
	if (Get-AppxPackage -Name Microsoft.WindowsTerminal)
	{
		# Show the option in the Desktop context menu
		if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\Directory\Background\shell\runas\command))
		{
			New-Item -Path Registry::HKEY_CLASSES_ROOT\Directory\Background\shell\runas\command -ItemType Directory -Force
		}
		New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\Directory\Background\shell\runas -Name "(default)" -PropertyType String -Value $Localization.OpenInWindowsTerminalAdmin -Force
		New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\Directory\Background\shell\runas -Name Icon -PropertyType String -Value "imageres.dll,73" -Force
		New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\Directory\Background\shell\runas -Name NoWorkingDirectory -PropertyType String -Value "" -Force
		New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\Directory\Background\shell\runas\command -Name "(default)" -PropertyType String -Value "wt.exe -d ""%V""" -Force

		# Show the option in the folders context menu
		if (-not (Test-Path -Path Registry::HKEY_CLASSES_ROOT\Directory\shell\runas\command))
		{
			New-Item -Path Registry::HKEY_CLASSES_ROOT\Directory\shell\runas\command -ItemType Directory -Force
		}
		New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\Directory\shell\runas -Name "(default)" -PropertyType String -Value $Localization.OpenInWindowsTerminalAdmin -Force
		New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\Directory\shell\runas -Name Icon -PropertyType String -Value "imageres.dll,73" -Force
		New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\Directory\shell\runas -Name NoWorkingDirectory -PropertyType String -Value "" -Force
		New-ItemProperty -Path Registry::HKEY_CLASSES_ROOT\Directory\shell\runas\command -Name "(default)" -PropertyType String -Value "wt.exe -d ""%1""" -Force
	}
}




#endregion Context menu

#region Other

# Make the taskbar size large
Function LargeTaskbarSize {
	Write-Output "Setting Large Taskbar Size ..."
	New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarSi -PropertyType DWord -Value 2 -Force
}

# Make the taskbar size default
Function DefaultTaskbarSize {
	Write-Output "Setting Default Taskbar Size ..."
	New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarSi -PropertyType DWord -Value 1 -Force
}

# Make the taskbar size small
Function SmallTaskbarSize {
	Write-Output "Setting Small Taskbar Size ..."
	New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarSi -PropertyType DWord -Value 0 -Force
}

# Taskbar Always combine, hide labels
Function AlwaysCombineHideLabelsTaskbar {
	Write-Output "Setting Taskbar to Always combine, hide labels ..."
	New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarGlomLevel -PropertyType DWord -Value 0 -Force
}

# Taskbar Combine when taskbar is full
Function CombineWhenFullTaskbar {
	Write-Output "Setting Taskbar to combine when taskbar is full ..."
	New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarGlomLevel -PropertyType DWord -Value 1 -Force
}

# Taskbar Never combine
Function NeverCombineTaskbar {
	Write-Output "Setting Taskbar to never combine ..."
	New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name TaskbarGlomLevel -PropertyType DWord -Value 2 -Force
}

# View the Control Panel icons by category
Function CategoryControlPanelView {
	Write-Output "Setting Category Control Panel View ..."
	if (-not (Test-Path -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel))
	{
		New-Item -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force
	}
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name AllItemsIconView -PropertyType DWord -Value 0 -Force
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name StartupPage -PropertyType DWord -Value 0 -Force
}

# View the Control Panel icons by large icons
Function LargeIconsControlPanelView {
	Write-Output "Setting Large Icons Control Panel View ..."
	if (-not (Test-Path -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel))
	{
		New-Item -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force
	}
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name AllItemsIconView -PropertyType DWord -Value 0 -Force
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name StartupPage -PropertyType DWord -Value 1 -Force
}

# View the Control Panel icons by small icons
Function SmallIconsControlPanelView {
	Write-Output "Setting Small Icons Control Panel View ..."
	if (-not (Test-Path -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel))
	{
		New-Item -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Force
	}
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name AllItemsIconView -PropertyType DWord -Value 1 -Force
	New-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel -Name StartupPage -PropertyType DWord -Value 1 -Force
}

#endregion Other


# Holder for None (Must keep)
Function None {
}

# Relaunch the script with administrator privileges
Function RequireAdmin {
	If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]"Administrator")) {
		Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`" $PSCommandArgs" -WorkingDirectory $pwd -Verb RunAs
		Exit
	}
}

# Create Restore Point
Function CreateRestorePoint {
  Write-Output "Creating Restore Point incase something bad happens"
  Enable-ComputerRestore -Drive "C:\"
  Checkpoint-Computer -Description "RestorePoint1" -RestorePointType "MODIFY_SETTINGS"
}

# Normalize path to preset file
$preset = ""
$PSCommandArgs = $args
If ($args -And $args[0].ToLower() -eq "-preset") {
	$preset = Resolve-Path $($args | Select-Object -Skip 1)
	$PSCommandArgs = "-preset `"$preset`""
}

# Load function names from command line arguments or a preset file
If ($args) {
	$tweaks = $args
	If ($preset) {
		$tweaks = Get-Content $preset -ErrorAction Stop | ForEach { $_.Trim() } | Where { $_ -ne "" -and $_[0] -ne "#" }
	}
}

# Call the desired tweak functions
$tweaks | ForEach { Invoke-Expression $_ }