Fully unattended Windows 11 Pro build using Autounattend.xml, swtpm for TPM 2.0 emulation, and VirtIO drivers. Five PowerShell provisioners strip bloatware, telemetry, unused services, and apply performance tuning for a resource-constrained host. Output is a compressed QCOW2 image. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
32 lines
1.2 KiB
PowerShell
32 lines
1.2 KiB
PowerShell
#Requires -RunAsAdministrator
|
|
|
|
# Windows Update cache
|
|
Stop-Service wuauserv -Force -ErrorAction SilentlyContinue
|
|
Remove-Item "C:\Windows\SoftwareDistribution\Download\*" -Recurse -Force -ErrorAction SilentlyContinue
|
|
Start-Service wuauserv -ErrorAction SilentlyContinue
|
|
|
|
# Temp folders
|
|
Remove-Item "$env:TEMP\*" -Recurse -Force -ErrorAction SilentlyContinue
|
|
Remove-Item "C:\Windows\Temp\*" -Recurse -Force -ErrorAction SilentlyContinue
|
|
|
|
# Windows Error Reporting archives
|
|
Remove-Item "C:\ProgramData\Microsoft\Windows\WER\*" -Recurse -Force -ErrorAction SilentlyContinue
|
|
Remove-Item "C:\Windows\Minidump\*" -Force -ErrorAction SilentlyContinue
|
|
Remove-Item "C:\Windows\MEMORY.DMP" -Force -ErrorAction SilentlyContinue
|
|
|
|
# Prefetch (small, but consistent)
|
|
Remove-Item "C:\Windows\Prefetch\*" -Force -ErrorAction SilentlyContinue
|
|
|
|
# Event logs
|
|
Get-EventLog -LogName * -ErrorAction SilentlyContinue | ForEach-Object {
|
|
Clear-EventLog -LogName $_.Log -ErrorAction SilentlyContinue
|
|
}
|
|
|
|
# DISM: remove superseded Windows component store entries
|
|
DISM /Online /Cleanup-Image /StartComponentCleanup /ResetBase
|
|
|
|
# Compact OS: reduces on-disk footprint using XPRESS4K compression
|
|
Compact.exe /CompactOS:Always
|
|
|
|
Write-Output "Cleanup complete."
|