AWS Tools for Powershell Get-EC2Instance Filter

Viewed 6632

Is it possible to filter EC2 Instances by machine hostname? I am trying to find an internal instance but I don't have the IP address or the instanceId. I can't find any examples but I am thinking something this.

$instanceName = "MYMACHINEHOSTNAME"
$filter = New-Object Amazon.EC2.Model.Filter
$filter.Name = "Hostname"
$filter.Value = "$instanceName"
$ec2Instances = (Get-EC2Instance -Region us-west-2 -Filter $filter).Instances

Has anyone done anything like this?

Thanks,

Rhonda

1 Answers
Related