One thing I am missing in the Amazon Web Services interface/dashboard is the ability to see information from both the VPC and the instance in one screen.
For example: I want the name of the vpc, the vpc id, the name of the instance, the instance id, the state of the vpc and the name of the keypair it’s using.
For this, I’ve written the following small script, just to get a quick overview:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
$Instances = (Get-EC2Instance).instances $VPCS = Get-EC2Vpc foreach ($VPC in $VPCS) { $Instances | Where-Object {$_.VpcId -eq $VPC.VpcId} | foreach { New-Object -TypeName PSObject -Property @{ 'VpcId' = $_.VpcId 'VPCName' = ($VPC.Tags | Where-Object {$_.Key -eq 'Name'}).Value 'InstanceId' = $_.InstanceId 'InstanceName' = ($_.Tags | Where-Object {$_.Key -eq 'Name'}).Value 'LaunchTime' = $_.LaunchTime 'State' = $_.State.Name 'KeyName' = $_.KeyName } } } |
Note: A next step could be that you can turn this into a function and pipe this function to Out-GridView 🙂
Hi,
Some really cool blogs/scripts.
Maybe a silly question, but how would you output this is a grid view. I can’t seem to figure it out.
$Instances = (Get-EC2Instance).instances
$VPCS = Get-EC2Vpc
$Output = foreach ($VPC in $VPCS) {
$Instances | Where-Object {$_.VpcId -eq $VPC.VpcId} | foreach {
New-Object -TypeName PSObject -Property @{
‘VpcId’ = $_.VpcId
‘VPCName’ = ($VPC.Tags | Where-Object {$_.Key -eq ‘Name’}).Value
‘InstanceId’ = $_.InstanceId
‘InstanceName’ = ($_.Tags | Where-Object {$_.Key -eq ‘Name’}).Value
‘LaunchTime’ = $_.LaunchTime
‘State’ = $_.State.Name
‘KeyName’ = $_.KeyName
}
}
}
$Output | out-gridview
Hi Jeff,
Your scripts are really useful, can i knew where i can find more aws scirpts from your webpage, as there is nosearch option to find scripts related to aws.
Hope to hear from you soon.
Cheers
Aqeel