Created
April 6, 2019 01:01
-
-
Save MatthewJDavis/872c2cb9ba1fc0e95ce2d864c5810541 to your computer and use it in GitHub Desktop.
Handy ec2 commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Output the instance name from the tag along with a few properties | |
| $ec2 = Get-EC2Instance | |
| ($ec2).Instances | ForEach-Object { | |
| $properties = [ordered]@{ | |
| Name = ($_ | Select-Object -ExpandProperty tags | Where-Object -Property Key -eq Name ).value | |
| InsanceID = $_.InstanceId | |
| PrivateIP = $_.PrivateIpAddress | |
| SubnetId = $_.SubnetId | |
| InstanceType = $_.InstanceType | |
| } | |
| New-Object -TypeName PSObject -Property $properties | |
| } | |
| # Find EC2 Instance by name tag | |
| $ec2 = Get-EC2Instance -Filter @( @{name='tag:Name' ; values="Name-*"}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment