2

Powershell is not my strong point, but I'm trying to work on it. With that being said, I found this command that gives me most of the info I need about my AWS EC2 instances, but it's missing the actual name of the servers. Anyone know how to modify it to get the names it to show? Thanks in advance!!

(Get-EC2Instance).Instances

2

2 Answers 2

5

I was able to run the following command and got the results I needed.

(Get-Ec2Instance).Instances | select InstanceId, PublicDnsName, PrivateIpAddress, RootDeviceName, RootDeviceType, ImageId, @{Name="AWS Servername";Expression={$_.tags | where key -eq "Name" | select Value -expand Value}} | Out-GridView

Thanks for the help!!

Sign up to request clarification or add additional context in comments.

Comments

1

Try:

(Get-EC2Instance).Instances.PublicDnsName

You can use the command get-member to view all available properties:

PS C:\Users\mine> (Get-EC2Instance).Instances | get-member

Name                   MemberType    Definition                                                                                                 
----                   ----------    ----------                                                                                                 
Tag                    AliasProperty Tag = Tags                                                                                                 
Equals                 Method        bool Equals(System.Object obj)                                                                             
GetHashCode            Method        int GetHashCode()                                                                                          
GetType                Method        type GetType()                                                                                             
ToString               Method        string ToString()                                                                                          
AmiLaunchIndex         Property      int AmiLaunchIndex {get;set;}                                                                              
Architecture           Property      Amazon.EC2.ArchitectureValues Architecture {get;set;}                                                      
BlockDeviceMappings    Property      System.Collections.Generic.List[Amazon.EC2.Model.InstanceBlockDeviceMapping] BlockDeviceMappings {get;set;}
ClientToken            Property      string ClientToken {get;set;}                                                                              
CpuOptions             Property      Amazon.EC2.Model.CpuOptions CpuOptions {get;set;}                                                          
EbsOptimized           Property      bool EbsOptimized {get;set;}                                                                               
ElasticGpuAssociations Property      System.Collections.Generic.List[Amazon.EC2.Model.ElasticGpuAssociation] ElasticGpuAssociations {get;set;}  
EnaSupport             Property      bool EnaSupport {get;set;}                                                                                 
Hypervisor             Property      Amazon.EC2.HypervisorType Hypervisor {get;set;}                                                            
IamInstanceProfile     Property      Amazon.EC2.Model.IamInstanceProfile IamInstanceProfile {get;set;}                                          
ImageId                Property      string ImageId {get;set;}                                                                                  
InstanceId             Property      string InstanceId {get;set;}                                                                               
InstanceLifecycle      Property      Amazon.EC2.InstanceLifecycleType InstanceLifecycle {get;set;}                                              
InstanceType           Property      Amazon.EC2.InstanceType InstanceType {get;set;}                                                            
KernelId               Property      string KernelId {get;set;}                                                                                 
KeyName                Property      string KeyName {get;set;}                                                                                  
LaunchTime             Property      datetime LaunchTime {get;set;}                                                                             
Monitoring             Property      Amazon.EC2.Model.Monitoring Monitoring {get;set;}                                                          
NetworkInterfaces      Property      System.Collections.Generic.List[Amazon.EC2.Model.InstanceNetworkInterface] NetworkInterfaces {get;set;}    
Placement              Property      Amazon.EC2.Model.Placement Placement {get;set;}                                                            
Platform               Property      Amazon.EC2.PlatformValues Platform {get;set;}                                                              
PrivateDnsName         Property      string PrivateDnsName {get;set;}                                                                           
PrivateIpAddress       Property      string PrivateIpAddress {get;set;}                                                                         
ProductCodes           Property      System.Collections.Generic.List[Amazon.EC2.Model.ProductCode] ProductCodes {get;set;}                      
PublicDnsName          Property      string PublicDnsName {get;set;}                                                                            
PublicIpAddress        Property      string PublicIpAddress {get;set;}                                                                          
RamdiskId              Property      string RamdiskId {get;set;}                                                                                
RootDeviceName         Property      string RootDeviceName {get;set;}                                                                           
RootDeviceType         Property      Amazon.EC2.DeviceType RootDeviceType {get;set;}                                                            
SecurityGroups         Property      System.Collections.Generic.List[Amazon.EC2.Model.GroupIdentifier] SecurityGroups {get;set;}                
SourceDestCheck        Property      bool SourceDestCheck {get;set;}                                                                            
SpotInstanceRequestId  Property      string SpotInstanceRequestId {get;set;}                                                                    
SriovNetSupport        Property      string SriovNetSupport {get;set;}                                                                          
State                  Property      Amazon.EC2.Model.InstanceState State {get;set;}                                                            
StateReason            Property      Amazon.EC2.Model.StateReason StateReason {get;set;}                                                        
StateTransitionReason  Property      string StateTransitionReason {get;set;}                                                                    
SubnetId               Property      string SubnetId {get;set;}                                                                                 
Tags                   Property      System.Collections.Generic.List[Amazon.EC2.Model.Tag] Tags {get;set;}                                      
VirtualizationType     Property      Amazon.EC2.VirtualizationType VirtualizationType {get;set;}                                                
VpcId                  Property      string VpcId {get;set;}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.