Skip to content

Instantly share code, notes, and snippets.

@mbrouwer
Created July 11, 2018 07:51
Show Gist options
  • Save mbrouwer/7b6c4eac7449793cba613658a58e46a5 to your computer and use it in GitHub Desktop.
Save mbrouwer/7b6c4eac7449793cba613658a58e46a5 to your computer and use it in GitHub Desktop.
Sysprep Script
write-host "Remove unattended.xml"
if ( Test-Path $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml ) { rm $Env:SystemRoot\\windows\\system32\\Sysprep\\unattend.xml -Force}
& $env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /quiet /quit
write-host "SysPrep image"
while ($true) {
$imageState = Get-ItemProperty HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup\\State | Select ImageState
if ($imageState.ImageState -ne 'IMAGE_STATE_GENERALIZE_RESEAL_TO_OOBE') {
Write-Output $imageState.ImageState
Start-Sleep -s 10
}
else {
break
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment