Reputation: 1201
I was able to pull the PrivateIpAddress attached to the EC2 instance using below script but trying to find a way to get all the 'Secondary private IPs'
$fltr = New-Object Amazon.EC2.Model.Filter
$fltr.Name = 'tag:Name'
$fltr.Values = 'server01'
$e=Get-EC2Instance -Filter $fltr
$e.Instances.PrivateIpAddress
Upvotes: 3
Views: 843
Reputation: 1201
I have found a solution for this.
$fltr = New-Object Amazon.EC2.Model.Filter
$fltr.Name = 'tag:Name'
$fltr.Values = 'server01'
$e=Get-EC2Instance -Filter $fltr
$e.Instances.PrivateIpAddress
(Get-EC2NetworkInterface -Filter @{Name='addresses.private-ip-address';values=$e.Instances.PrivateIpAddress} |
select -ExpandProperty PrivateIpAddresses |
where{$_.primary -ne $true}).PrivateIpAddress
Upvotes: 2