Scripts/New-WindowsInstall.ps1


cd\


# Rename-Computer -NewName "" #-Restart
# Add-Computer -DomainName test.local -OUPath "OU=Servers, OU=Klant, DC=test, DC=local"


# Enable ping
Get-NetFirewallRule -DisplayGroup 'Core Networking Diagnostics' | Enable-NetFirewallRule

Set-TimeZone "W. Europe Standard Time"




#############################################
# PowerShell #
#############################################

if (!(Test-Path $profile)) {

    $ProfileContents = 'cd\
    # Chocolatey profile
    $ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
    if (Test-Path($ChocolateyProfile)) {
      Import-Module "$ChocolateyProfile"
    }
    '


    New-Item (Split-Path $PROFILE) -Type Directory -ErrorAction 0
    New-Item $PROFILE -Type file -Value $ProfileContents -ErrorAction 0

}

Install-PackageProvider -Name NuGet -Force
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted

Install-Module packagemanagement -Force
Install-Module JaapsTools


#############################################
# Windows settings #
#############################################

#Set DPI 100
Start-BitsTransfer -Source "https://github.com/imniko/SetDPI/releases/download/v0.2/SetDpi.exe" -Destination $([Environment]::GetFolderPath("CommonApplicationData"))
C:\ProgramData\SetDpi.exe 100
C:\ProgramData\SetDpi.exe 1 100


UserAccountControlSettings.exe
mmsys.cpl


# Disable Autoplay
Write-Host "Disabling Autoplay..."
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers" -Name "DisableAutoplay" -Type DWord -Value 1

# Disable Autorun for all drives
Write-Host "Disabling Autorun for all drives..."
If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer")) {
    New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" | Out-Null
}
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "NoDriveTypeAutoRun" -Type DWord -Value 255

# Disable Sticky keys prompt
Write-Host "Disabling Sticky keys prompt..."
Set-ItemProperty -Path "HKCU:\Control Panel\Accessibility\StickyKeys" -Name "Flags" -Type String -Value "506"


# Unpin Store from Taskbar

if ((Test-Path -LiteralPath "HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer") -ne $true) {
    New-Item "HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer" -Force -ea SilentlyContinue
}
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer' -Name 'NoPinningStoreToTaskbar' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue

# Hide Search button / box
Write-Host "Hiding Search Box / Button..."
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "SearchboxTaskbarMode" -Type DWord -Value 0
# Taskbar combining
New-ItemProperty "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name TaskbarGlomLevel -PropertyType DWORD -Value 2 -Force
# Tray icons
New-ItemProperty "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" -Name EnableAutoTray -PropertyType DWORD -Value 0 -Force
# Explorer settings
Set-ItemProperty "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name Hidden -Value 1
Set-ItemProperty "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name HideFileExt -Value 0
Set-ItemProperty "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name LaunchTo -Value 1
Set-ItemProperty "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name ShowSuperHidden -Value 0
Set-ItemProperty "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Ribbon" -Name MinimizedStateTabletModeOff -Value 0


New-ItemProperty "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize" -Name "AppsUseLightTheme" -Value "0" -PropertyType DWORD -Force
New-ItemProperty "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize" -Name "SystemUsesLightTheme" -Value "0" -PropertyType DWORD -Force

Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowTaskViewButton" -Type DWord -Value 0

New-ItemProperty HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name DontUsePowerShellOnWinx -PropertyType DWORD -Value 0 -Force

if ((Test-Path -LiteralPath "HKCU:\Control Panel\Desktop") -ne $true) {
    New-Item "HKCU:\Control Panel\Desktop" -Force -ea SilentlyContinue
}
if ((Test-Path -LiteralPath "HKCU:\Control Panel\Colors") -ne $true) {
    New-Item "HKCU:\Control Panel\Colors" -Force -ea SilentlyContinue
}
New-ItemProperty -LiteralPath 'HKCU:\Control Panel\Desktop' -Name 'WallPaper' -Value '' -PropertyType String -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\Control Panel\Colors' -Name 'Background' -Value '20 20 20' -PropertyType String -Force -ea SilentlyContinue

if (Get-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Feeds" -Name "ShellFeedsTaskbarViewMode" -ea 0) {
    Get-Process explorer | Stop-Process; New-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Feeds' -Name "ShellFeedsTaskbarViewMode" -Value 2 -PropertyType DWORD -Force
}

$WindowsEdition = (Get-WindowsEdition -Online).Edition
if ($WindowsEdition -like "*server*") {
    New-ItemProperty -Path HKCU:Software\Microsoft\ServerManager -Name DoNotOpenServerManagerAtLogon -PropertyType DWORD -Value "0x1" -Force

    # IE ESC mode disabled
    # $AdminKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}"
    # $UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}"
    # Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0 -Force
    # Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0 -Force

}




#############################################
# Edge settings #
#############################################


if ((Test-Path -LiteralPath "HKCU:\SOFTWARE\Policies\Microsoft\Edge") -ne $true) {
    New-Item "HKCU:\SOFTWARE\Policies\Microsoft\Edge" -Force -ea SilentlyContinue
}
if ((Test-Path -LiteralPath "HKCU:\SOFTWARE\Policies\Microsoft\Edge\Recommended") -ne $true) {
    New-Item "HKCU:\SOFTWARE\Policies\Microsoft\Edge\Recommended" -Force -ea SilentlyContinue
}
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Policies\Microsoft\Edge' -Name 'HideRestoreDialogEnabled' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Policies\Microsoft\Edge' -Name 'NewTabPageManagedQuickLinks' -Value '[ { "url": "https://outook.office.com", "title": "Outlook", "pinned": false } ]' -PropertyType String -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Policies\Microsoft\Edge' -Name 'HideFirstRunExperience' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Policies\Microsoft\Edge' -Name 'SmartScreenPuaEnabled' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Policies\Microsoft\Edge' -Name 'NewTabPageSearchBox' -Value 'redirect' -PropertyType String -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Policies\Microsoft\Edge' -Name 'ForceSync' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Policies\Microsoft\Edge' -Name 'EdgeShoppingAssistantEnabled' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Policies\Microsoft\Edge' -Name 'ShowMicrosoftRewards' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Policies\Microsoft\Edge' -Name 'ShowRecommendationsEnabled' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Policies\Microsoft\Edge' -Name 'NewTabPageContentEnabled' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Policies\Microsoft\Edge' -Name 'NewTabPageAllowedBackgroundTypes' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Policies\Microsoft\Edge' -Name 'NewTabPageHideDefaultTopSites' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Policies\Microsoft\Edge' -Name 'MicrosoftEdgeInsiderPromotionEnabled' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Policies\Microsoft\Edge' -Name 'BlockThirdPartyCookies' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Policies\Microsoft\Edge' -Name 'BrowserSignin' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Policies\Microsoft\Edge' -Name 'ConfigureOnlineTextToSpeech' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Policies\Microsoft\Edge' -Name 'PromotionalTabsEnabled' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Policies\Microsoft\Edge' -Name 'DefaultNotificationsSetting' -Value 2 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Policies\Microsoft\Edge' -Name 'DefaultSearchProviderEnabled' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Policies\Microsoft\Edge' -Name 'DefaultSearchProviderImageURL' -Value '{google:baseURL}searchbyimage/upload' -PropertyType String -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Policies\Microsoft\Edge' -Name 'DefaultSearchProviderName' -Value 'Google' -PropertyType String -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Policies\Microsoft\Edge' -Name 'DefaultSearchProviderSearchURL' -Value '{google:baseURL}search?q={searchTerms}&{google:RLZ}{google:originalQueryForSuggestion}{google:assistedQueryStats}{google:searchFieldtrialParameter}{google:searchClient}{google:sourceId}ie={inputEncoding}' -PropertyType String -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Policies\Microsoft\Edge' -Name 'DefaultSearchProviderSuggestURL' -Value '{google:baseURL}complete/search?output=chrome&q={searchTerms}' -PropertyType String -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Policies\Microsoft\Edge' -Name 'SmartScreenEnabled' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Policies\Microsoft\Edge\Recommended' -Name 'ControlDefaultStateOfAllowExtensionFromOtherStoresSettingEnabled' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Policies\Microsoft\Edge\Recommended' -Name 'FavoritesBarEnabled' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue


#############################################
# Office settings #
#############################################

New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Microsoft\Office\16.0\Outlook\Options\Calendar' -Name 'WeekNum' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Microsoft\Office\16.0\Outlook\Options\Reminders' -Name 'PlaySound' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Microsoft\Office\16.0\Outlook\Message' -Name 'DisableReadingPaneCompose' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Microsoft\Office\16.0\Outlook\Preferences' -Name 'EnableSingleLineRibbon' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Microsoft\Office\16.0\Outlook\Preferences' -Name 'PlaySound' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Microsoft\Office\16.0\Outlook\Preferences' -Name 'ShowEnvelope' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Microsoft\Office\16.0\Outlook\Preferences' -Name 'NewmailDesktopAlerts' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Microsoft\Office\16.0\Outlook\Preferences' -Name 'PreviewMarkMessage' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Microsoft\Office\16.0\Outlook\Preferences' -Name 'PreviewWaitSeconds' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Microsoft\Office\16.0\Outlook\Preferences' -Name 'PreviewDontMarkUntilChange' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Microsoft\Office\16.0\Outlook\Preferences' -Name 'ReadingPaneSelectItem' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Microsoft\Office\16.0\Outlook\Preferences' -Name 'DensitySetting' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Microsoft\Office\16.0\Outlook\Preferences' -Name 'ShowBcc' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Microsoft\Office\16.0\Outlook\Preferences' -Name 'ShowAutoSug' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Microsoft\Office\16.0\Word\Options' -Name 'PasteFormattingWithin' -Value 2 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Microsoft\Office\16.0\Word\Options' -Name 'PasteFormattingTwoDocumentsNoStyles' -Value 2 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Microsoft\Office\16.0\Word\Options' -Name 'PasteFormattingOtherApp' -Value 2 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Microsoft\Office\16.0\Word\Options' -Name 'PasteFormattingTwoDocumentsWithStyles' -Value 2 -PropertyType DWord -Force -ea SilentlyContinue


#############################################
# 7-zip settings #
#############################################


if ((Test-Path -LiteralPath "HKCU:\SOFTWARE\7-Zip\Options") -ne $true) {
    New-Item "HKCU:\SOFTWARE\7-Zip\Options" -Force -ea SilentlyContinue
}
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\7-Zip\Options' -Name 'CascadedMenu' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\7-Zip\Options' -Name 'ContextMenu' -Value 4391 -PropertyType DWord -Force -ea SilentlyContinue
New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\7-Zip\Options' -Name 'MenuIcons' -Value 1 -PropertyType DWord -Force -ea SilentlyContinue



#############################################
# Chocolatey #
#############################################


# Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

choco feature enable -n allowGlobalConfirmation



#############################################
# Uninstall Apps #
#############################################

Get-AppxPackage "Microsoft.BingWeather" | Remove-AppxPackage
Get-AppxPackage "Microsoft.Getstarted" | Remove-AppxPackage
Get-AppxPackage "Microsoft.MicrosoftOfficeHub" | Remove-AppxPackage
Get-AppxPackage "Microsoft.MicrosoftSolitaireCollection" | Remove-AppxPackage
Get-AppxPackage "Microsoft.People" | Remove-AppxPackage
Get-AppxPackage "Microsoft.SkypeApp" | Remove-AppxPackage
Get-AppxPackage "microsoft.windowscommunicationsapps" | Remove-AppxPackage
Get-AppxPackage "Microsoft.WindowsMaps" | Remove-AppxPackage
Get-AppxPackage "Microsoft.WindowsFeedbackHub" | Remove-AppxPackage
Get-AppxPackage "Microsoft.GetHelp" | Remove-AppxPackage
Get-AppxPackage "Microsoft.MicrosoftStickyNotes" | Remove-AppxPackage
Get-AppxPackage "Microsoft.BingNews" | Remove-AppxPackage


# Install

choco install 7zip
choco install notepadplusplus.install
choco install treesizefree

choco install vscode
# choco install vscode-powershell

choco install vlc

choco install bandlab-assistant --ignore-checksums
choco install nvidia-display-driver
choco install Shotcut
choco install steam
choco pin add --name='steam'
choco install spotify
choco pin add --name='spotify'
choco install asio4all
# choco install microsoft-edge

choco install signal
choco pin add --name='signal'

choco install office365business --params='/exclude:"Publisher Outlook Access Lync"'
choco pin add --name='Office365Business'

# choco install forticlientvpn

# choco install powertoys
# choco install epicgameslauncher
# choco pin add --name='epicgameslauncher'



# OneDrive Always available offline

attrib.exe +P "$([Environment]::GetFolderPath("MyDocuments"))\WindowsPowerShell\*" /D /S






### Windows 11

# ExplorerPatch (Win11)
Invoke-WebRequest "https://github.com/valinet/ExplorerPatcher/releases/latest/download/ep_setup.exe" -OutFile $env:TEMP\ep_setup.exe
Start-Process $env:TEMP\ep_setup.exe



# Uninstall Teams Home
winget uninstall MicrosoftTeams_8wekyb3d8bbwe