Created
April 21, 2016 12:28
-
-
Save avvi00/9525f5b2ba5956c692c30274c755d3cc to your computer and use it in GitHub Desktop.
Get a collection of ec2 instance names (from tag) with associated security groups
This file contains 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
Get-EC2Instance | | |
Select -ExpandProperty Instances | | |
Select -Property @{ | |
Name='InstanceId' | |
Expression={$_.InstanceId} | |
}, | |
@{ | |
Name='SecurityGroups' | |
Expression = {$_.SecurityGroups | Select -ExpandProperty GroupId} | |
}, | |
@{ | |
Name='TagName' | |
Expression={$_.Tags | ? {$_.Key -eq 'Name'} | Select -ExpandProperty Value } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment