View a markdown version of this page

Amazon EC2 examples using Tools for PowerShell V5 - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Amazon EC2 examples using Tools for PowerShell V5

The following code examples show you how to perform actions and implement common scenarios by using the AWS Tools for PowerShell V5 with Amazon EC2.

Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.

Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.

Topics

Actions

The following code example shows how to use Add-EC2CapacityReservation.

Tools for PowerShell V5

Example 1: This example creates a new Capacity Reservation with the specified attributes

Add-EC2CapacityReservation -InstanceType m4.xlarge -InstanceCount 2 -AvailabilityZone eu-west-1b -EbsOptimized True -InstancePlatform Windows

Output:

AvailabilityZone : eu-west-1b AvailableInstanceCount : 2 CapacityReservationId : cr-0c1f2345db6f7cdba CreateDate : 3/28/2019 9:29:41 AM EbsOptimized : True EndDate : 1/1/0001 12:00:00 AM EndDateType : unlimited EphemeralStorage : False InstanceMatchCriteria : open InstancePlatform : Windows InstanceType : m4.xlarge State : active Tags : {} Tenancy : default TotalInstanceCount : 2

The following code example shows how to use Add-EC2InternetGateway.

Tools for PowerShell V5

Example 1: This example attaches the specified Internet gateway to the specified VPC.

Add-EC2InternetGateway -InternetGatewayId igw-1a2b3c4d -VpcId vpc-12345678

Example 2: This example creates a VPC and an Internet gateway, and then attaches the Internet gateway to the VPC.

$vpc = New-EC2Vpc -CidrBlock 10.0.0.0/16 New-EC2InternetGateway | Add-EC2InternetGateway -VpcId $vpc.VpcId

The following code example shows how to use Add-EC2NetworkInterface.

Tools for PowerShell V5

Example 1: This example attaches the specified network interface to the specified instance.

Add-EC2NetworkInterface -NetworkInterfaceId eni-12345678 -InstanceId i-1a2b3c4d -DeviceIndex 1

Output:

eni-attach-1a2b3c4d

The following code example shows how to use Add-EC2Volume.

Tools for PowerShell V5

Example 1: This example attaches the specified volume to the specified instance and exposes it with the specified device name.

Add-EC2Volume -VolumeId vol-12345678 -InstanceId i-1a2b3c4d -Device /dev/sdh

Output:

AttachTime : 12/22/2015 1:53:58 AM DeleteOnTermination : False Device : /dev/sdh InstanceId : i-1a2b3c4d State : attaching VolumeId : vol-12345678
  • For API details, see AttachVolume in AWS Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Add-EC2VpnGateway.

Tools for PowerShell V5

Example 1: This example attaches the specified virtual private gateway to the specified VPC.

Add-EC2VpnGateway -VpnGatewayId vgw-1a2b3c4d -VpcId vpc-12345678

Output:

State VpcId ----- ----- attaching vpc-12345678
  • For API details, see AttachVpnGateway in AWS Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Approve-EC2VpcPeeringConnection.

Tools for PowerShell V5

Example 1: This example approves the requested VpcPeeringConnectionId pcx-1dfad234b56ff78be

Approve-EC2VpcPeeringConnection -VpcPeeringConnectionId pcx-1dfad234b56ff78be

Output:

AccepterVpcInfo : Amazon.EC2.Model.VpcPeeringConnectionVpcInfo ExpirationTime : 1/1/0001 12:00:00 AM RequesterVpcInfo : Amazon.EC2.Model.VpcPeeringConnectionVpcInfo Status : Amazon.EC2.Model.VpcPeeringConnectionStateReason Tags : {} VpcPeeringConnectionId : pcx-1dfad234b56ff78be

The following code example shows how to use Confirm-EC2ProductInstance.

Tools for PowerShell V5

Example 1: This example determines whether the specified product code is associated with the specified instance.

Confirm-EC2ProductInstance -ProductCode 774F4FF8 -InstanceId i-12345678

The following code example shows how to use Copy-EC2Image.

Tools for PowerShell V5

Example 1: This example copies the specified AMI in the 'EU (Ireland)' region to the 'US West (Oregon)' region. If -Region is not specified, the current default region is used as the destination region.

Copy-EC2Image -SourceRegion eu-west-1 -SourceImageId ami-12345678 -Region us-west-2 -Name "Copy of ami-12345678"

Output:

ami-87654321
  • For API details, see CopyImage in AWS Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Copy-EC2Snapshot.

Tools for PowerShell V5

Example 1: This example copies the specified snapshot from the EU (Ireland) region to the US West (Oregon) region.

Copy-EC2Snapshot -SourceRegion eu-west-1 -SourceSnapshotId snap-12345678 -Region us-west-2

Example 2: If you set a default region and omit the Region parameter, the default destination region is the default region.

Set-DefaultAWSRegion us-west-2 Copy-EC2Snapshot -SourceRegion eu-west-1 -SourceSnapshotId snap-12345678
  • For API details, see CopySnapshot in AWS Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Deny-EC2VpcPeeringConnection.

Tools for PowerShell V5

Example 1: The above example denies the request for VpcPeering request id pcx-01a2b3ce45fe67eb8

Deny-EC2VpcPeeringConnection -VpcPeeringConnectionId pcx-01a2b3ce45fe67eb8

The following code example shows how to use Disable-EC2VgwRoutePropagation.

Tools for PowerShell V5

Example 1: This example disables the VGW from automatically propagating routes to the specified routing table.

Disable-EC2VgwRoutePropagation -RouteTableId rtb-12345678 -GatewayId vgw-1a2b3c4d

The following code example shows how to use Disable-EC2VpcClassicLink.

Tools for PowerShell V5

Example 1: This example disables EC2VpcClassicLink for the vpc-01e23c4a5d6db78e9. It returns either True or False

Disable-EC2VpcClassicLink -VpcId vpc-01e23c4a5d6db78e9

The following code example shows how to use Disable-EC2VpcClassicLinkDnsSupport.

Tools for PowerShell V5

Example 1: This example disables ClassicLink DNS support for the vpc-0b12d3456a7e8910d

Disable-EC2VpcClassicLinkDnsSupport -VpcId vpc-0b12d3456a7e8910d

The following code example shows how to use Dismount-EC2InternetGateway.

Tools for PowerShell V5

Example 1: This example detaches the specified Internet gateway from the specified VPC.

Dismount-EC2InternetGateway -InternetGatewayId igw-1a2b3c4d -VpcId vpc-12345678

The following code example shows how to use Dismount-EC2NetworkInterface.

Tools for PowerShell V5

Example 1: This example removes the specified attachment between a network interface and an instance.

Dismount-EC2NetworkInterface -AttachmentId eni-attach-1a2b3c4d -Force

The following code example shows how to use Dismount-EC2Volume.

Tools for PowerShell V5

Example 1: This example detaches the specified volume.

Dismount-EC2Volume -VolumeId vol-12345678

Output:

AttachTime : 12/22/2015 1:53:58 AM DeleteOnTermination : False Device : /dev/sdh InstanceId : i-1a2b3c4d State : detaching VolumeId : vol-12345678

Example 2: You can also specify the instance ID and device name to ensure that you are detaching the correct volume.

Dismount-EC2Volume -VolumeId vol-12345678 -InstanceId i-1a2b3c4d -Device /dev/sdh
  • For API details, see DetachVolume in AWS Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Dismount-EC2VpnGateway.

Tools for PowerShell V5

Example 1: This example detaches the specified virtual private gateway from the specified VPC.

Dismount-EC2VpnGateway -VpnGatewayId vgw-1a2b3c4d -VpcId vpc-12345678
  • For API details, see DetachVpnGateway in AWS Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Edit-EC2CapacityReservation.

Tools for PowerShell V5

Example 1: This example modifies the CapacityReservationId cr-0c1f2345db6f7cdba by changing the instane count to 1

Edit-EC2CapacityReservation -CapacityReservationId cr-0c1f2345db6f7cdba -InstanceCount 1

Output:

True

The following code example shows how to use Edit-EC2Host.

Tools for PowerShell V5

Example 1: This example modifies the AutoPlacement settings to off for the dedicated host h-01e23f4cd567890f3

Edit-EC2Host -HostId h-03e09f8cd681609f3 -AutoPlacement off

Output:

Successful Unsuccessful ---------- ------------ {h-01e23f4cd567890f3} {}
  • For API details, see ModifyHosts in AWS Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Edit-EC2IdFormat.

Tools for PowerShell V5

Example 1: This example enables the longer ID format for the specified resource type.

Edit-EC2IdFormat -Resource instance -UseLongId $true

Example 2: This example disables the longer ID format for the specified resource type.

Edit-EC2IdFormat -Resource instance -UseLongId $false
  • For API details, see ModifyIdFormat in AWS Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Edit-EC2ImageAttribute.

Tools for PowerShell V5

Example 1: This example updates the description for the specified AMI.

Edit-EC2ImageAttribute -ImageId ami-12345678 -Description "New description"

Example 2: This example makes the AMI public (for example, so any AWS account can use it).

Edit-EC2ImageAttribute -ImageId ami-12345678 -Attribute launchPermission -OperationType add -UserGroup all

Example 3: This example makes the AMI private (for example, so that only you as the owner can use it).

Edit-EC2ImageAttribute -ImageId ami-12345678 -Attribute launchPermission -OperationType remove -UserGroup all

Example 4: This example grants launch permission to the specified AWS account.

Edit-EC2ImageAttribute -ImageId ami-12345678 -Attribute launchPermission -OperationType add -UserId 111122223333

Example 5: This example removes launch permission from the specified AWS account.

Edit-EC2ImageAttribute -ImageId ami-12345678 -Attribute launchPermission -OperationType remove -UserId 111122223333

The following code example shows how to use Edit-EC2InstanceAttribute.

Tools for PowerShell V5

Example 1: This example modifies the instance type of the specified instance.

Edit-EC2InstanceAttribute -InstanceId i-12345678 -InstanceType m3.medium

Example 2: This example enables enhanced networking for the specified instance, by specifying "simple" as the value of the single root I/O virtualization (SR-IOV) network support parameter, -SriovNetSupport..

Edit-EC2InstanceAttribute -InstanceId i-12345678 -SriovNetSupport "simple"

Example 3: This example modifies the security groups for the specified instance. The instance must be in a VPC. You must specify the ID of each security group, not the name.

Edit-EC2InstanceAttribute -InstanceId i-12345678 -Group @( "sg-12345678", "sg-45678901" )

Example 4: This example enables EBS I/O optimization for the specified instance. This feature isn't available with all instance types. Additional usage charges apply when using an EBS-optimized instance.

Edit-EC2InstanceAttribute -InstanceId i-12345678 -EbsOptimized $true

Example 5: This example enables source/destination checking for the specified instance. For a NAT instance to perform NAT, the value must be 'false'.

Edit-EC2InstanceAttribute -InstanceId i-12345678 -SourceDestCheck $true

Example 6: This example disables termination for the specified instance.

Edit-EC2InstanceAttribute -InstanceId i-12345678 -DisableApiTermination $true

Example 7: This example changes the specified instance so that it terminates when shutdown is initiated from the instance.

Edit-EC2InstanceAttribute -InstanceId i-12345678 -InstanceInitiatedShutdownBehavior terminate

The following code example shows how to use Edit-EC2InstanceCreditSpecification.

Tools for PowerShell V5

Example 1: This enables T2 unlimited credits for instance i-01234567890abcdef.

$Credit = New-Object -TypeName Amazon.EC2.Model.InstanceCreditSpecificationRequest $Credit.InstanceId = "i-01234567890abcdef" $Credit.CpuCredits = "unlimited" Edit-EC2InstanceCreditSpecification -InstanceCreditSpecification $Credit

The following code example shows how to use Edit-EC2NetworkInterfaceAttribute.

Tools for PowerShell V5

Example 1: This example modifies the specified network interface so that the specified attachment is deleted on termination.

Edit-EC2NetworkInterfaceAttribute -NetworkInterfaceId eni-1a2b3c4d -Attachment_AttachmentId eni-attach-1a2b3c4d -Attachment_DeleteOnTermination $true

Example 2: This example modifies the description of the specified network interface.

Edit-EC2NetworkInterfaceAttribute -NetworkInterfaceId eni-1a2b3c4d -Description "my description"

Example 3: This example modifies the security group for the specified network interface.

Edit-EC2NetworkInterfaceAttribute -NetworkInterfaceId eni-1a2b3c4d -Groups sg-1a2b3c4d

Example 4: This example disables source/destination checking for the specified network interface.

Edit-EC2NetworkInterfaceAttribute -NetworkInterfaceId eni-1a2b3c4d -SourceDestCheck $false

The following code example shows how to use Edit-EC2ReservedInstance.

Tools for PowerShell V5

Example 1: This example modifies the Availability Zone, instance count, and platform for the specified Reserved instances.

$config = New-Object Amazon.EC2.Model.ReservedInstancesConfiguration $config.AvailabilityZone = "us-west-2a" $config.InstanceCount = 1 $config.Platform = "EC2-VPC" Edit-EC2ReservedInstance ` -ReservedInstancesId @("FE32132D-70D5-4795-B400-AE435EXAMPLE", "0CC556F3-7AB8-4C00-B0E5-98666EXAMPLE") ` -TargetConfiguration $config

The following code example shows how to use Edit-EC2SnapshotAttribute.

Tools for PowerShell V5

Example 1: This example makes the specified snapshot public by setting its CreateVolumePermission attribute.

Edit-EC2SnapshotAttribute -SnapshotId snap-12345678 -Attribute CreateVolumePermission -OperationType Add -GroupName all

The following code example shows how to use Edit-EC2SpotFleetRequest.

Tools for PowerShell V5

Example 1: This example updates the target capacity of the specified Spot fleet request.

Edit-EC2SpotFleetRequest -SpotFleetRequestId sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE -TargetCapacity 10

Output:

True

The following code example shows how to use Edit-EC2SubnetAttribute.

Tools for PowerShell V5

Example 1: This example enables public IP addressing for the specified subnet.

Edit-EC2SubnetAttribute -SubnetId subnet-1a2b3c4d -MapPublicIpOnLaunch $true

Example 2: This example disables public IP addressing for the specified subnet.

Edit-EC2SubnetAttribute -SubnetId subnet-1a2b3c4d -MapPublicIpOnLaunch $false

The following code example shows how to use Edit-EC2VolumeAttribute.

Tools for PowerShell V5

Example 1: This example modifies the specified attribute of the specified volume. I/O operations for the volume are automatically resumed after being suspended due to potentially inconsistent data.

Edit-EC2VolumeAttribute -VolumeId vol-12345678 -AutoEnableIO $true

The following code example shows how to use Edit-EC2VpcAttribute.

Tools for PowerShell V5

Example 1: This example enables support for DNS hostnames for the specified VPC.

Edit-EC2VpcAttribute -VpcId vpc-12345678 -EnableDnsHostnames $true

Example 2: This example disables support for DNS hostnames for the specified VPC.

Edit-EC2VpcAttribute -VpcId vpc-12345678 -EnableDnsHostnames $false

Example 3: This example enables support for DNS resolution for the specified VPC.

Edit-EC2VpcAttribute -VpcId vpc-12345678 -EnableDnsSupport $true

Example 4: This example disables support for DNS resolution for the specified VPC.

Edit-EC2VpcAttribute -VpcId vpc-12345678 -EnableDnsSupport $false
  • For API details, see ModifyVpcAttribute in AWS Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Enable-EC2VgwRoutePropagation.

Tools for PowerShell V5

Example 1: This example enables the specified VGW to propagate routes automatically to the specified routing table.

Enable-EC2VgwRoutePropagation -RouteTableId rtb-12345678 -GatewayId vgw-1a2b3c4d

The following code example shows how to use Enable-EC2VolumeIO.

Tools for PowerShell V5

Example 1: This example enables I/O operations for the specified volume, if I/O operations were disabled.

Enable-EC2VolumeIO -VolumeId vol-12345678
  • For API details, see EnableVolumeIo in AWS Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Enable-EC2VpcClassicLink.

Tools for PowerShell V5

Example 1: This example enables VPC vpc-0123456b789b0d12f for ClassicLink

Enable-EC2VpcClassicLink -VpcId vpc-0123456b789b0d12f

Output:

True

The following code example shows how to use Enable-EC2VpcClassicLinkDnsSupport.

Tools for PowerShell V5

Example 1: This example enables vpc-0b12d3456a7e8910d to support DNS hostname resolution for ClassicLink

Enable-EC2VpcClassicLinkDnsSupport -VpcId vpc-0b12d3456a7e8910d -Region eu-west-1

The following code example shows how to use Get-EC2AccountAttribute.

Tools for PowerShell V5

Example 1: This example describes whether you can launch instances into EC2-Classic and EC2-VPC in the region, or only into EC2-VPC.

(Get-EC2AccountAttribute -AttributeName supported-platforms).AttributeValues

Output:

AttributeValue -------------- EC2 VPC

Example 2: This example describes your default VPC, or is 'none' if you do not have a default VPC in the region.

(Get-EC2AccountAttribute -AttributeName default-vpc).AttributeValues

Output:

AttributeValue -------------- vpc-12345678

Example 3: This example describes the maximum number of On-Demand instances that you can run.

(Get-EC2AccountAttribute -AttributeName max-instances).AttributeValues

Output:

AttributeValue -------------- 20

The following code example shows how to use Get-EC2Address.

Tools for PowerShell V5

Example 1: This example describes the specified Elastic IP address for instances in EC2-Classic.

Get-EC2Address -AllocationId eipalloc-12345678

Output:

AllocationId : eipalloc-12345678 AssociationId : eipassoc-12345678 Domain : vpc InstanceId : i-87654321 NetworkInterfaceId : eni-12345678 NetworkInterfaceOwnerId : 12345678 PrivateIpAddress : 10.0.2.172 PublicIp : 198.51.100.2

Example 2: This example describes your Elastic IP addresses for instances in a VPC. This syntax requires PowerShell version 3 or later.

Get-EC2Address -Filter @{ Name="domain";Values="vpc" }

Example 3: This example describes the specified Elastic IP address for instances in EC2-Classic.

Get-EC2Address -PublicIp 203.0.113.17

Output:

AllocationId : AssociationId : Domain : standard InstanceId : i-12345678 NetworkInterfaceId : NetworkInterfaceOwnerId : PrivateIpAddress : PublicIp : 203.0.113.17

Example 4: This example describes your Elastic IP addresses for instances in EC2-Classic. This syntax requires PowerShell version 3 or later.

Get-EC2Address -Filter @{ Name="domain";Values="standard" }

Example 5: This example describes all your Elastic IP addresses.

Get-EC2Address

Example 6: This example returns the public and private IP for the instance id provided in filter

Get-EC2Address -Region eu-west-1 -Filter @{Name="instance-id";Values="i-0c12d3f4f567ffb89"} | Select-Object PrivateIpAddress, PublicIp

Output:

PrivateIpAddress PublicIp ---------------- -------- 10.0.0.99 63.36.5.227

Example 7: This example retrieves all the Elastic IPs with its allocation id, association id and instance ids

Get-EC2Address -Region eu-west-1 | Select-Object InstanceId, AssociationId, AllocationId, PublicIp

Output:

InstanceId AssociationId AllocationId PublicIp ---------- ------------- ------------ -------- eipalloc-012e3b456789e1fad 17.212.120.178 i-0c123dfd3415bac67 eipassoc-0e123456bb7890bdb eipalloc-01cd23ebf45f7890c 17.212.124.77 eipalloc-012345678eeabcfad 17.212.225.7 i-0123d405c67e89a0c eipassoc-0c123b456783966ba eipalloc-0123cdd456a8f7892 37.216.52.173 i-0f1bf2f34c5678d09 eipassoc-0e12934568a952d96 eipalloc-0e1c23e4d5e6789e4 37.218.222.278 i-012e3cb4df567e8aa eipassoc-0d1b2fa4d67d03810 eipalloc-0123f456f78a01b58 37.210.82.27 i-0123bcf4b567890e1 eipassoc-01d2345f678903fb1 eipalloc-0e1db23cfef5c45c7 37.215.222.270

Example 8: This example fetches list of EC2 IP addresses matching tag key 'Category' with value 'Prod'

Get-EC2Address -Filter @{Name="tag:Category";Values="Prod"}

Output:

AllocationId : eipalloc-0123f456f81a01b58 AssociationId : eipassoc-0d1b23a456d103810 CustomerOwnedIp : CustomerOwnedIpv4Pool : Domain : vpc InstanceId : i-012e3cb4df567e1aa NetworkBorderGroup : eu-west-1 NetworkInterfaceId : eni-0123f41d5a60d5f40 NetworkInterfaceOwnerId : 123456789012 PrivateIpAddress : 192.168.1.84 PublicIp : 34.250.81.29 PublicIpv4Pool : amazon Tags : {Category, Name}
  • For API details, see DescribeAddresses in AWS Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Get-EC2AvailabilityZone.

Tools for PowerShell V5

Example 1: This example describes the Availability Zones for the current region that are available to you.

Get-EC2AvailabilityZone

Output:

Messages RegionName State ZoneName -------- ---------- ----- -------- {} us-west-2 available us-west-2a {} us-west-2 available us-west-2b {} us-west-2 available us-west-2c

Example 2: This example describes any Availability Zones that are in an impaired state. The syntax used by this example requires PowerShell version 3 or higher.

Get-EC2AvailabilityZone -Filter @{ Name="state";Values="impaired" }

Example 3: With PowerShell version 2, you must use New-Object to create the filter.

$filter = New-Object Amazon.EC2.Model.Filter $filter.Name = "state" $filter.Values = "impaired" Get-EC2AvailabilityZone -Filter $filter

The following code example shows how to use Get-EC2BundleTask.

Tools for PowerShell V5

Example 1: This example describes the specified bundle task.

Get-EC2BundleTask -BundleId bun-12345678

Example 2: This example describes the bundle tasks whose state is either 'complete' or 'failed'.

$filter = New-Object Amazon.EC2.Model.Filter $filter.Name = "state" $filter.Values = @( "complete", "failed" ) Get-EC2BundleTask -Filter $filter

The following code example shows how to use Get-EC2CapacityReservation.

Tools for PowerShell V5

Example 1: This example describes one or more of your Capacity Reservations for the region

Get-EC2CapacityReservation -Region eu-west-1

Output:

AvailabilityZone : eu-west-1b AvailableInstanceCount : 2 CapacityReservationId : cr-0c1f2345db6f7cdba CreateDate : 3/28/2019 9:29:41 AM EbsOptimized : True EndDate : 1/1/0001 12:00:00 AM EndDateType : unlimited EphemeralStorage : False InstanceMatchCriteria : open InstancePlatform : Windows InstanceType : m4.xlarge State : active Tags : {} Tenancy : default TotalInstanceCount : 2

The following code example shows how to use Get-EC2ConsoleOutput.

Tools for PowerShell V5

Example 1: This example gets the console output for the specified Linux instance. The console output is encoded.

Get-EC2ConsoleOutput -InstanceId i-0e19abcd47c123456

Output:

InstanceId Output ---------- ------ i-0e194d3c47c123637 WyAgICAwLjAwMDAwMF0gQ29tbW...bGU9dHR5UzAgc2Vs

Example 2: This example stores the encoded console output in a variable and then decodes it.

$Output_encoded = (Get-EC2ConsoleOutput -InstanceId i-0e19abcd47c123456).Output [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($Output_encoded))
  • For API details, see GetConsoleOutput in AWS Tools for PowerShell Cmdlet Reference (V5).

The following code example shows how to use Get-EC2CustomerGateway.

Tools for PowerShell V5

Example 1: This example describes the specified customer gateway.

Get-EC2CustomerGateway -CustomerGatewayId cgw-1a2b3c4d

Output:

BgpAsn : 65534 CustomerGatewayId : cgw-1a2b3c4d IpAddress : 203.0.113.12 State : available Tags : {} Type : ipsec.1

Example 2: This example describes any customer gateway whose state is either pending or available.

$filter = New-Object Amazon.EC2.Model.Filter $filter.Name = "state" $filter.Values = @( "pending", "available" ) Get-EC2CustomerGateway -Filter $filter

Example 3: This example describes all your customer gateways.

Get-EC2CustomerGateway

The following code example shows how to use Get-EC2DhcpOption.