Scripts/New-WindowsInstall.ps1


cd\


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


Set-TimeZone "W. Europe Standard Time"



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

}

UserAccountControlSettings.exe
mmsys.cpl


#System settings


Set-ExecutionPolicy RemoteSigned -Force -Scope CurrentUser


# 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




# Powershell


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

Install-Module packagemanagement -Force
Install-Module JaapsTools

# UI customisation

# 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

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


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") {
    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

}

# 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

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














# Set fixed IP Address
if ((Get-NetAdapter).count -gt 1) {
    Get-NetAdapter
    Write-Host "Choose interface index" -ForegroundColor Yellow
    $IfIndex = Read-Host -Prompt "Choose interface index"
    if (Get-NetAdapter -ifIndex $IfIndex -ea 0) {
    } else {
        Write-Host "Interface with index $IfIndex does not exist" -ForegroundColor Red
        Remove-Variable IfIndex
    }
} else {
    $IfIndex = (Get-NetAdapter).InterfaceIndex
}

if ($IfIndex) {
    New-NetIPAddress -IPAddress 192.168.2.63 -DefaultGateway 192.168.2.1 -PrefixLength 24 -InterfaceIndex $IfIndex
    Set-DnsClientServerAddress -ServerAddresses 192.168.2.60 -InterfaceIndex $IfIndex
}