i want to retrieve an ec2 instance's ID from it's name which I have set as the value of it's tag. I have a VM with key as 'Name' and value as 'testvm1'. Is there something like
(get-ec2 instance id) | where-object {$_.(key.value) - eq "testvm1"}
this worked
$ec2Name = New-Object Amazon.EC2.Model.Filter -Property @{Name = "tag:Name"; Values = "testvm1"}
$instances = @(Get-EC2Tag -Filters $ec2Name)
$instances | Select-Object -ExpandProperty resourceid