A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.aws.amazon.com/powershell/latest/reference/items/Get-EC2Instance.html below:

EC2: Get-EC2Instance Cmdlet | AWS Tools for PowerShell

Example 1

(Get-EC2Instance -InstanceId i-12345678).Instances

AmiLaunchIndex : 0

Architecture : x86_64

BlockDeviceMappings : {/dev/sda1}

ClientToken : TleEy1448154045270

EbsOptimized : False

Hypervisor : xen

IamInstanceProfile : Amazon.EC2.Model.IamInstanceProfile

ImageId : ami-12345678

InstanceId : i-12345678

InstanceLifecycle :

InstanceType : t2.micro

KernelId :

KeyName : my-key-pair

LaunchTime : 12/4/2015 4:44:40 PM

Monitoring : Amazon.EC2.Model.Monitoring

NetworkInterfaces : {ip-10-0-2-172.us-west-2.compute.internal}

Placement : Amazon.EC2.Model.Placement

Platform : Windows

PrivateDnsName : ip-10-0-2-172.us-west-2.compute.internal

PrivateIpAddress : 10.0.2.172

ProductCodes : {}

PublicDnsName :

PublicIpAddress :

RamdiskId :

RootDeviceName : /dev/sda1

RootDeviceType : ebs

SecurityGroups : {default}

SourceDestCheck : True

SpotInstanceRequestId :

SriovNetSupport :

State : Amazon.EC2.Model.InstanceState

StateReason :

StateTransitionReason :

SubnetId : subnet-12345678

Tags : {Name}

VirtualizationType : hvm

VpcId : vpc-12345678

This example describes the specified instance.

Example 2

Get-EC2Instance

GroupNames : {}

Groups : {}

Instances : {}

OwnerId : 123456789012

RequesterId : 226008221399

ReservationId : r-c5df370c

GroupNames : {}

Groups : {}

Instances : {}

OwnerId : 123456789012

RequesterId : 854251627541

ReservationId : r-63e65bab

...

This example describes all your instances in the current region, grouped by reservation. To see the instance details expand the Instances collection within each reservation object.

Example 3

(Get-EC2Instance -Filter @{Name="vpc-id";Values="vpc-1a2bc34d"},@{Name="subnet-id";Values="subnet-1a2b3c4d"}).Instances

InstanceId InstanceType Platform PrivateIpAddress PublicIpAddress SecurityGroups SubnetId VpcId

---------- ------------ -------- ---------------- --------------- -------------- -------- -----

i-01af...82cf180e19 t2.medium Windows 10.0.0.98 ... subnet-1a2b3c4d vpc-1a2b3c4d

i-0374...7e9d5b0c45 t2.xlarge Windows 10.0.0.53 ... subnet-1a2b3c4d vpc-1a2b3c4d

This example illustrates using a filter to query for EC2 instances in a specific subnet of a VPC.

Example 4

$InstanceParams = @{

Filter = @(

@{'Name' = 'instance-state-name';'Values' = @("running","stopped")}

)

}

(Get-EC2Instance @InstanceParams).Instances

InstanceId InstanceType Platform PrivateIpAddress PublicIpAddress SecurityGroups SubnetId VpcId

---------- ------------ -------- ---------------- --------------- -------------- -------- -----

i-05a9...f6c5f46e18 t3.medium 10.0.1.7 ... subnet-1a2b3c4d vpc-1a2b3c4d

i-02cf...945c4fdd07 t3.medium Windows 10.0.1.8 ... subnet-1a2b3c4d vpc-1a2b3c4d

i-0ac0...c037f9f3a1 t3.xlarge Windows 10.0.1.10 ... subnet-1a2b3c4d vpc-1a2b3c4d

i-066b...57b7b08888 t3.medium Windows 10.0.1.11 ... subnet-1a2b3c4d vpc-1a2b3c4d

i-0fee...82e83ccd72 t3.medium Windows 10.0.1.5 ... subnet-1a2b3c4d vpc-1a2b3c4d

i-0a68...274cc5043b t3.medium Windows 10.0.1.6 ... subnet-1a2b3c4d vpc-1a2b3c4d

This example illustrates using a filter with multiple values to query for EC2 instances that are both running and stopped

Example 5

$InstanceParams = @{

Filter = @(

@{'Name' = 'instance-state-name';'Values' = @("running","stopped")}

)

}

$SelectParams = @{

Property = @(

"InstanceID", "InstanceType", "Platform", "PrivateIpAddress",

@{Name="Name";Expression={$_.Tags[$_.Tags.Key.IndexOf("Name")].Value}},

@{Name="State";Expression={$_.State.Name}}

)

}

$result = Get-EC2Instance @InstanceParams

$result.Instances | Select-Object @SelectParams | Format-Table -AutoSize

InstanceId InstanceType Platform PrivateIpAddress Name State

---------- ------------ -------- ---------------- ---- -----

i-05a9...f6c5f46e18 t3.medium 10.0.1.7 ec2-name-01 running

i-02cf...945c4fdd07 t3.medium Windows 10.0.1.8 ec2-name-02 stopped

i-0ac0...c037f9f3a1 t3.xlarge Windows 10.0.1.10 ec2-name-03 running

i-066b...57b7b08888 t3.medium Windows 10.0.1.11 ec2-name-04 stopped

i-0fee...82e83ccd72 t3.medium Windows 10.0.1.5 ec2-name-05 running

i-0a68...274cc5043b t3.medium Windows 10.0.1.6 ec2-name-06 stopped

This example illustrates using a filter with multiple values to query for EC2 instances that are both running and stopped and using the Select-Object cmdlet for choosing specific values to output.

Example 6

Get-EC2Tag -DryRun $true

Get-EC2Instance: Request would have succeeded, but DryRun flag is set.

This example validates permissions for getting EC2 instances using the DryRun parameter without actually fetching them. Note: This throws an exception if succeeded which is the expected behavior.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4