繁体   English   中英

显示服务器名称的AWS EC2 Powershell命令/脚本

[英]AWS EC2 Powershell Command / Script To Show Server Names

Powershell不是我的强项,但我正在努力。 话虽这么说,我发现该命令为我提供了有关我的AWS EC2实例所需的大部分信息,但它缺少服务器的实际名称。 有人知道如何对其进行修改以使其显示名称吗? 提前致谢!!

(GET-EC2Instance).Instances

尝试:

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

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

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

谢谢您的帮助!!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM