Version 5 (V5) of the AWS Tools for PowerShell has been released!
For information about breaking changes and migrating your applications, see the migration topic.
Find an Amazon Machine Image Using Windows PowerShell
When you launch an Amazon EC2 instance, you specify an Amazon Machine Image (AMI) to serve as a template for the instance. However, the IDs for the AWS Windows AMIs change frequently because AWS provides new AMIs with the latest updates and security enhancements. You can use the Get-EC2Image cmdlet to find the current Windows AMIs and get their IDs.
Get-EC2Image
The Get-EC2Image
cmdlet retrieves a list of AMIs that you can use.
Use the -Owner
parameter with the array value amazon, self
so that
Get-EC2Image
retrieves only AMIs that belong to Amazon or to you. In this context,
you refers to the user whose credentials you used to invoke the cmdlet.
PS >
Get-EC2Image -Owner amazon, self
You can scope the results using the -Filter
parameter. To specify the filter, create an
object of type Amazon.EC2.Model.Filter
. For example, use the following filter to display
only Windows AMIs.
$platform_values = New-Object 'collections.generic.list[string]' $platform_values.add("windows") $filter_platform = New-Object Amazon.EC2.Model.Filter -Property @{Name = "platform"; Values = $platform_values} Get-EC2Image -Owner amazon, self -Filter $filter_platform
The following is an example of one of the AMIs returned by the cmdlet; the actual output of the previous command provides information for many AMIs.
Architecture : x86_64
BlockDeviceMappings : {/dev/sda1, xvdca, xvdcb, xvdcc…}
CreationDate : 2019-06-12T10:41:31.000Z
Description : Microsoft Windows Server 2019 Full Locale English with SQL Web 2017 AMI provided by Amazon
EnaSupport : True
Hypervisor : xen
ImageId : ami-000226b77608d973b
ImageLocation : amazon/Windows_Server-2019-English-Full-SQL_2017_Web-2019.06.12
ImageOwnerAlias : amazon
ImageType : machine
KernelId :
Name : Windows_Server-2019-English-Full-SQL_2017_Web-2019.06.12
OwnerId : 801119661308
Platform : Windows
ProductCodes : {}
Public : True
RamdiskId :
RootDeviceName : /dev/sda1
RootDeviceType : ebs
SriovNetSupport : simple
State : available
StateReason :
Tags : {}
VirtualizationType : hvm
Note
Version 4 of the AWS Tools for PowerShell provided the Get-EC2ImageByName
cmdlet to filter the list
of AMIs by name patterns. For version 5 of the tools, use the Get-SSMLatestEC2Image cmdlet
instead.