Because we are deploying EC2 Microsoft Windows Server 2022 Base, in the search box, enter and select EC2LaunchSettings
Note: in fact, if you run other versions of windows such as: Windows Server 2008, Windows Server 2012 R2,… see more configuration instructions in document AWS
The EC2LaunchSettings window appears, in the Administrator Password settings section, select Random
At the bottom of the page, Select Shutdown without Sysprep
You asked about Windows need your confirmation to execute sysprep for creating the image and shutting down the virtual machine! select Yes
Result:
At some point you will see the RDP notification: session has ended. Quickly return to the EC2 console and notice that EC2 Windows-instance has stopped
Noted: By Shutting down with Sysprep your AMI will remove unique information, such as the version security identifier (SID), computer name and driver. You will avoid the error of not being able to Get password as shown below:
Of course, when you encounter a warning as shown below, you can proceed to reset the key pair through the lab exercise 5.5 Solving the Issue of Lost Access Key Pair. However, imagine when you have dozens or hundreds of EC2 instances created from this Image through lab 5.4, you will also need a corresponding number of times to reset the key pair, instead, use the sysprep function to retrieve the new passwordand make accessing the EC2 windows instance more convenient.