Skip to content

Instantly share code, notes, and snippets.

@babakc
Last active March 18, 2017 21:47
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 babakc/88e15cc00bbb817f6ae10c4a7c0e49f7 to your computer and use it in GitHub Desktop.
Save babakc/88e15cc00bbb817f6ae10c4a7c0e49f7 to your computer and use it in GitHub Desktop.
# Finally, perform sysprep.
# Start sysprep but quit instead of shutdown
Start-Process -FilePath $sysprepPath -ArgumentList ("/oobe /quit /generalize `"/unattend:{0}`"" -f $answerFilePath) -Wait -NoNewWindow
# Replace windeploy.exe with the custom PowerShell startup script
Set-ItemProperty -Path HKLM:\System\setup -Name CmdLine -Value "powershell.exe -command c:\Scripts\startup.ps1"
# Delete the existing route to query instance metadata
route delete 169.254.169.254
# Shutdown the host
Stop-Computer -Force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment