Find an Amazon Machine Image Using Windows PowerShell - Amazon Tools for PowerShell
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

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 Amazon Windows AMIs change frequently because Amazon provides new AMIs with the latest updates and security enhancements. You can use the Get-EC2Image and Get-EC2ImageByName cmdlets 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

Get-EC2ImageByName

The Get-EC2ImageByName cmdlet enables you to filter the list of Amazon Windows AMIs based on the type of server configuration you are interested in.

When run with no parameters, as follows, the cmdlet emits the complete set of current filter names:

PS > Get-EC2ImageByName WINDOWS_2016_BASE WINDOWS_2016_NANO WINDOWS_2016_CORE WINDOWS_2016_CONTAINER WINDOWS_2016_SQL_SERVER_ENTERPRISE_2016 WINDOWS_2016_SQL_SERVER_STANDARD_2016 WINDOWS_2016_SQL_SERVER_WEB_2016 WINDOWS_2016_SQL_SERVER_EXPRESS_2016 WINDOWS_2012R2_BASE WINDOWS_2012R2_CORE WINDOWS_2012R2_SQL_SERVER_EXPRESS_2016 WINDOWS_2012R2_SQL_SERVER_STANDARD_2016 WINDOWS_2012R2_SQL_SERVER_WEB_2016 WINDOWS_2012R2_SQL_SERVER_EXPRESS_2014 WINDOWS_2012R2_SQL_SERVER_STANDARD_2014 WINDOWS_2012R2_SQL_SERVER_WEB_2014 WINDOWS_2012_BASE WINDOWS_2012_SQL_SERVER_EXPRESS_2014 WINDOWS_2012_SQL_SERVER_STANDARD_2014 WINDOWS_2012_SQL_SERVER_WEB_2014 WINDOWS_2012_SQL_SERVER_EXPRESS_2012 WINDOWS_2012_SQL_SERVER_STANDARD_2012 WINDOWS_2012_SQL_SERVER_WEB_2012 WINDOWS_2012_SQL_SERVER_EXPRESS_2008 WINDOWS_2012_SQL_SERVER_STANDARD_2008 WINDOWS_2012_SQL_SERVER_WEB_2008 WINDOWS_2008R2_BASE WINDOWS_2008R2_SQL_SERVER_EXPRESS_2012 WINDOWS_2008R2_SQL_SERVER_STANDARD_2012 WINDOWS_2008R2_SQL_SERVER_WEB_2012 WINDOWS_2008R2_SQL_SERVER_EXPRESS_2008 WINDOWS_2008R2_SQL_SERVER_STANDARD_2008 WINDOWS_2008R2_SQL_SERVER_WEB_2008 WINDOWS_2008RTM_BASE WINDOWS_2008RTM_SQL_SERVER_EXPRESS_2008 WINDOWS_2008RTM_SQL_SERVER_STANDARD_2008 WINDOWS_2008_BEANSTALK_IIS75 WINDOWS_2012_BEANSTALK_IIS8 VPC_NAT

To narrow the set of images returned, specify one or more filter names using the Names parameter.

PS > Get-EC2ImageByName -Names WINDOWS_2016_CORE Architecture : x86_64 BlockDeviceMappings : {/dev/sda1, xvdca, xvdcb, xvdcc…} CreationDate : 2019-08-16T09:36:09.000Z Description : Microsoft Windows Server 2016 Core Locale English AMI provided by Amazon EnaSupport : True Hypervisor : xen ImageId : ami-06f2a2afca06f15fc ImageLocation : amazon/Windows_Server-2016-English-Core-Base-2019.08.16 ImageOwnerAlias : amazon ImageType : machine KernelId : Name : Windows_Server-2016-English-Core-Base-2019.08.16 OwnerId : 801119661308 Platform : Windows ProductCodes : {} Public : True RamdiskId : RootDeviceName : /dev/sda1 RootDeviceType : ebs SriovNetSupport : simple State : available StateReason : Tags : {} VirtualizationType : hvm