Skip to content

Instantly share code, notes, and snippets.

@BladeFireLight
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BladeFireLight/52ec11bb595163776b01 to your computer and use it in GitHub Desktop.
Save BladeFireLight/52ec11bb595163776b01 to your computer and use it in GitHub Desktop.
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
#endregion
#region sysprep
C:\Windows\System32\sysprep\sysprep.exe /quiet /generalize /oobe /shutdown /mode:vm
Stop-Transcript
#endregion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment