So I am attempting to use Amazons Ec2Config.exe -sysprep command to sysprep an instance and prepare it to be cloned into a new AMI with the programs I require installed. The following are the last two lines of code I run in this particular powershell.ps1 script and they are where things seem to go sideways(I've tried a few different methods of executing the .exe, all yielded the same results):
cd "C:\Program Files\Amazon\Ec2ConfigService\"
./Ec2Config.exe -sysprep
If I comment these lines out, log into the instance and run the exact same commands manually, things work as expected(Which implies that all of the related xml files are properly configured).
Now, here's where it gets interesting. When these lines are not commented out and the script runs them, I can log into the instance on which the script is being run and see the sysprep process running via process explorer, but it never finishes and the instance shuts down prematurely.
I believe at this point, considering I can see the process running in process explorer, I've ruled out it being a permissions error(the script is being run as the "NT AUTHORITY\SYSTEM" user with the RunLevel set to Highest).
My gut tells me that it's something related to the fact that the Ec2config.exe -sysprep does not allow you to pass in the '/quiet' option for sysprep, but I'm not certain if that matters.
Any ideas?
I have been having the same kind of issue. I found a script that Amazon created. It's located in "C:\Program Files\Amazon\Ec2ConfigService\Scripts". It's call InstallUpdates.ps1, and runs fine when you are logged in, and run from a admin powershell prompt. I have tried numerous things to get it to work remotely. The only way I could figure out how to get it to run remotelty is to run it by calling it from a batch file, but it just sits there. I've reached the same conclusion you have. I believe the /quiet needs to be passed to the sysprep cmd that ec2config is calling. Here is what I am doing in an attempt to add the /quiet:
$path = 'C:\Program Files\Amazon\Ec2ConfigService\Settings\BundleConfig.xml'
$BCxml = Get-Content $path
$BCxml = ($BCxml).replace('<Switches>/oobe /shutdown /generalize</Switches>', '<Switches>/oobe /shutdown /generalize /quiet</Switches>')
$BCxml | out-file $path -Force
I could have done this using some xml parsing, but this works, and is fewer lines. I just ran this and it works like a champ. Hope this helps.