Created
September 26, 2019 14:00
-
-
Save dsect/f01d8186c96c7d0be02be8547d247c1b to your computer and use it in GitHub Desktop.
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
| $Ec2Instances = @() | |
| $Instances = (Get-EC2Instance -Filter ` | |
| @( | |
| @{name = "tag:MyFirstTag"; values = "FirstTagValue" }, | |
| @{name = "tag:MySecondTag"; values = @("SecondTagValue1"; "SecondTagValue2") } | |
| ) | |
| ).Instances | |
| foreach ($Instance in $Instances) { | |
| $Ec2Instance = [pscustomobject]@{ | |
| Name = ($Instance.Tag | Where-Object { $_.Key -eq 'MyFirstTag' }).Value | |
| Environment = ($Instance.Tag | Where-Object { $_.Key -eq 'MySecondTag' }).Value | |
| } | |
| $Ec2Instances += $Ec2Instance | |
| # Do per-instance operations | |
| $Instance | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment