Skip to content

Instantly share code, notes, and snippets.

Last active Aug 29, 2015
What would you like to do?
SysPrep script for use with Start-ImageBuild.ps1
#requires -Version 1 -Modules ScheduledTasks, ServerManager
#region cleanup
Start-Transcript -Path c:\sysprep.log
Get-ScheduledTask -TaskName AtStartup | Unregister-ScheduledTask -Confirm:$false
Remove-Item -Path c:\unattend.xml
Get-ChildItem -Path c:\pstemp\ -Exclude AtStartup.ps1 | Remove-Item
Get-WindowsFeature |
Where-Object -FilterScript {
$_.Installed -eq 0 -and $_.InstallState -eq 'Available'
} |
Uninstall-WindowsFeature -remove
Dism.exe /online /cleanup-image /StartComponentCleanup /ResetBase
Defrag.exe c: /UVX
#region sysprep
C:\Windows\System32\sysprep\sysprep.exe /quiet /generalize /oobe /shutdown /mode:vm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment