Skip to content

Client Template Preparation Script

SettingValue
VM ID490
Nameclt-template-w11
OSWindows 11 Enterprise
Terminal window
<#
.SYNOPSIS
Windows 11 Client Template Preparation Script
.AUTHOR
Maurice Suter
.DATE
2025-12-22
#>
#Requires -RunAsAdministrator
$ErrorActionPreference = "Continue"
Write-Host "Starting Windows 11 Template Preparation..." -ForegroundColor Green
# ============================================================
# 1. REMOTE DESKTOP (Manual)
# ============================================================
# Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name "fDenyTSConnections" -Value 0
# Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
# ============================================================
# 2. FIREWALL - PING
# ============================================================
netsh advfirewall firewall set rule name="File and Printer Sharing (Echo Request - ICMPv4-In)" new enable=yes profile=any
# ============================================================
# 3. TIMEZONE
# ============================================================
Set-TimeZone -Id "W. Europe Standard Time"
# ============================================================
# 4. LANGUAGE & REGIONAL SETTINGS
# ============================================================
Set-WinUILanguageOverride en-US
Set-WinSystemLocale -SystemLocale en-US
Set-Culture de-CH
Set-WinUserLanguageList de-CH -Force
$1 = Get-WinUserLanguageList
$1.RemoveAll( { $args[0].LanguageTag -clike '' } )
$1.Add('de-CH')
Set-WinUserLanguageList $1 -Force
# ============================================================
# 5. POWER SETTINGS
# ============================================================
powercfg /setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
powercfg /change monitor-timeout-ac 0
powercfg /change standby-timeout-ac 0
# ============================================================
# 6. SYSPREP COUNTER RESET
# ============================================================
Set-ItemProperty -Path "HKLM:\SYSTEM\Setup\Status\SysprepStatus" -Name "CleanupState" -Value 2
Set-ItemProperty -Path "HKLM:\SYSTEM\Setup\Status\SysprepStatus" -Name "GeneralizationState" -Value 7
# ============================================================
# 7. CLEANUP
# ============================================================
Remove-Item -Path "$env:TEMP\*" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -Path "C:\Windows\Temp\*" -Recurse -Force -ErrorAction SilentlyContinue
wevtutil cl System
wevtutil cl Application
wevtutil cl Security
Write-Host "Preparation Complete! Run Sysprep via noVNC." -ForegroundColor Green
Terminal window
Set-NetIPInterface -InterfaceAlias "Ethernet" -Dhcp Enabled; Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ResetServerAddresses; Remove-Item -Path "$env:APPDATA\Microsoft\Windows\PowerShell\PSReadLine\*" -Force -ErrorAction SilentlyContinue; C:\Windows\System32\Sysprep\sysprep.exe /oobe /generalize /shutdown