1.asm虚拟机可以使用类似如下Azure Powershell命令获取虚拟机的基本信息,包括发行版本,虚拟机名称及size【备注:虚拟机需要是使用平台image创建的】

PS C:\Users\he.liming> $vm = Get-AzureVM -ServiceName hlmcla12r2n5c12617 -Name hlmclakey73n1
PS C:\Users\he.liming> $vm.VM.OSVirtualHardDisk
HostCaching     : ReadWrite
DiskLabel       :
DiskName        : hlmcla69n3-hlmclakey73n1-0-201709251058520037
MediaLink       : https://hlmstoragen.blob.core.chinacloudapi.cn/vhds/hlmcla12r2n5c12617-hlmclakey73n1-2017-09-25.vhd
SourceImageName : f1179221e23b4dbb89e39d70e5bc9e72__OpenLogic-CentOS-73-20170707
OS              : Linux
IOType          : Standard
ResizedSizeInGB :
ExtensionData   :

PS C:\Users\he.liming> $vm.VM.RoleName
hlmclakey73n1
PS C:\Users\he.liming> $vm.VM.RoleSize
Medium

 

2.arm虚拟机可以使用类似如下Azure Powershell命令获取虚拟机的基本信息,包括发行版本,虚拟机名称及size【备注:虚拟机需要是使用平台的image创建的】

PS C:\Users\he.liming> $vm = Get-AzureRmVM -ResourceGroupName hlmrgn -Name hlmcen69n1
PS C:\Users\he.liming> $vm.StorageProfile.ImageReference
Publisher : OpenLogic
Offer     : CentOS
Sku       : 6.9
Version   : latest
Id        :

PS C:\Users\he.liming> $vm.StorageProfile.OsDisk
OsType             : Linux
EncryptionSettings :
Name               : hlmcen69n1
Vhd                : Microsoft.Azure.Management.Compute.Models.VirtualHardDisk
Image              :
Caching            : ReadWrite
CreateOption       : FromImage
DiskSizeGB         : 30
ManagedDisk        :

PS C:\Users\he.liming> $vm.HardwareProfile
VmSize
------
Standard_A1

PS C:\Users\he.liming> $vm.Name
hlmcen69n1

 

3.可以使用“gm”【Get-Member】参数查看当前变量的方法及属性

PS C:\Users\he.liming> $vm | gm


   TypeName: Microsoft.WindowsAzure.Commands.ServiceManagement.Model.PersistentVMRoleContext

Name                              MemberType Definition
----                              ---------- ----------
Equals                            Method     bool Equals(System.Object obj)
GetHashCode                       Method     int GetHashCode()
GetInstance                       Method     Microsoft.WindowsAzure.Commands.ServiceManagement.Model.PersistentVM GetInstance(), Microsoft.WindowsAzure.Commands.ServiceManagement.Model.
GetType                           Method     type GetType()
ToString                          Method     string ToString()
AvailabilitySetName               Property   string AvailabilitySetName {get;set;}
DeploymentName                    Property   string DeploymentName {get;set;}
DNSName                           Property   string DNSName {get;set;}
GuestAgentStatus                  Property   Microsoft.WindowsAzure.Commands.ServiceManagement.Model.GuestAgentStatus GuestAgentStatus {get;set;}
HostName                          Property   string HostName {get;set;}
InstanceErrorCode                 Property   string InstanceErrorCode {get;set;}
InstanceFaultDomain               Property   string InstanceFaultDomain {get;set;}
InstanceName                      Property   string InstanceName {get;set;}
InstanceSize                      Property   string InstanceSize {get;set;}
InstanceStateDetails              Property   string InstanceStateDetails {get;set;}
InstanceStatus                    Property   string InstanceStatus {get;set;}
InstanceUpgradeDomain             Property   string InstanceUpgradeDomain {get;set;}
IpAddress                         Property   string IpAddress {get;set;}
Label                             Property   string Label {get;set;}
MaintenanceStatus                 Property   Microsoft.WindowsAzure.Commands.ServiceManagement.Model.MaintenanceStatus MaintenanceStatus {get;set;}
Name                              Property   string Name {get;set;}
NetworkInterfaces                 Property   Microsoft.WindowsAzure.Commands.ServiceManagement.Model.NetworkInterfaceList NetworkInterfaces {get;set;}
OperationDescription              Property   string OperationDescription {get;set;}
OperationId                       Property   string OperationId {get;set;}
OperationStatus                   Property   string OperationStatus {get;set;}
PowerState                        Property   string PowerState {get;set;}
PublicIPAddress                   Property   string PublicIPAddress {get;set;}
PublicIPDomainNameLabel           Property   string PublicIPDomainNameLabel {get;set;}
PublicIPFqdns                     Property   System.Collections.Generic.List[string] PublicIPFqdns {get;set;}
PublicIPName                      Property   string PublicIPName {get;set;}
RemoteAccessCertificateThumbprint Property   string RemoteAccessCertificateThumbprint {get;set;}
ResourceExtensionStatusList       Property   System.Collections.Generic.List[Microsoft.WindowsAzure.Commands.ServiceManagement.Model.ResourceExtensionStatus] ResourceExtensionStatusList
ServiceName                       Property   string ServiceName {get;set;}
Status                            Property   string Status {get;set;}
VirtualNetworkName                Property   string VirtualNetworkName {get;set;}
VM                                Property   Microsoft.WindowsAzure.Commands.ServiceManagement.Model.PersistentVM VM {get;set;}

 

posted on 2017-09-26 12:54  铭的随记  阅读(270)  评论(0编辑  收藏  举报