【问题标题】:AWS EC2 Powershell Command / Script To Show Server NamesAWS EC2 Powershell 命令/脚本来显示服务器名称
【发布时间】:2018-12-18 21:56:09
【问题描述】:

Powershell 不是我的强项,但我正在努力解决这个问题。话虽如此,我发现这个命令为我提供了有关我的 AWS EC2 实例所需的大部分信息,但它缺少服务器的实际名称。任何人都知道如何修改它以获取它显示的名称?提前致谢!!

(Get-EC2Instance).Instances

【问题讨论】:

标签: amazon-web-services powershell amazon-ec2


【解决方案1】:

我能够运行以下命令并获得所需的结果。

(Get-Ec2Instance).Instances |选择 InstanceId、PublicDnsName、PrivateIpAddress、RootDeviceName、RootDeviceType、ImageId、@{Name="AWS Servername";Expression={$_.tags |其中键-eq“名称”|选择值-展开值}} | Out-GridView

感谢您的帮助!

【讨论】:

    【解决方案2】:

    试试:

    (Get-EC2Instance).Instances.PublicDnsName
    

    您可以使用命令get-member 查看所有可用属性:

    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;}
    

    【讨论】:

      猜你喜欢
      • 2017-02-27
      • 2022-10-05
      • 2014-04-11
      • 1970-01-01
      • 2020-09-20
      • 1970-01-01
      • 2010-10-12
      • 2019-02-03
      • 2017-07-11
      相关资源
      最近更新 更多