Created
January 15, 2022 00:11
-
-
Save Rugby-Ball/06d539eaab7000d882fe48998d80f33a to your computer and use it in GitHub Desktop.
Scan Each Region, Each VPC, Each Subnet for Available ENI and count the IP's associated to the ENI. #Utility #AWS #Public #Inventory
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
| #Check-for-available-AWS-ENI.ps1 | |
| <# | |
| Scan Each Region, Each VPC, Each Subnet for Available ENI and count the IP's associated to the ENI. Use it to clean up un-used ENI and regain those Private IP's | |
| #> | |
| (Get-EC2Region).regionname | foreach { (Get-EC2Vpc -Region $_).vpcid | foreach { Get-EC2Subnet -Filter @{Name="vpc-id";Value="$_"} | foreach { Get-EC2NetworkInterface -Filter @(@{Name="subnet-id";Values=$_.subnetid} ; @{Name="status";Values="available"} ) | Select-Object VPCID, InterfaceType, NetworkInterfaceID, @{n="PrivateIP-Count"; e= {($_.privateipaddresses | Measure-Object).count}}, SubnetID, Status } } } | Format-Table -AutoSize |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment