你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Get-AzVmss

获取 VMSS 的属性。

语法

Get-AzVmss
   [[-ResourceGroupName] <String>]
   [[-VMScaleSetName] <String>]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Get-AzVmss
   [[-ResourceGroupName] <String>]
   [[-VMScaleSetName] <String>]
   [-InstanceView]
   [-UserData]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Get-AzVmss
   [[-ResourceGroupName] <String>]
   [[-VMScaleSetName] <String>]
   [-OSUpgradeHistory]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Get-AzVmss
   [-ResourceId <String>]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]

说明

Get-AzVmss cmdlet 获取虚拟机规模集(VMSS)的模型和实例视图。 模型视图是虚拟机规模集的用户指定属性。 实例视图是虚拟机规模集的实例级别状态。 指定 InstanceView 参数以仅获取虚拟机规模集的实例视图。

示例

示例 1:获取 VMSS 的属性

Get-AzVmss -ResourceGroupName "Group001" -VMScaleSetName "VMSS001"

ResourceGroupName                           : Group001
Sku                                         :
  Name                                      : Standard_DS1_v2
  Tier                                      : Standard
  Capacity                                  : 2
UpgradePolicy                               :
  Mode                                      : Manual
VirtualMachineProfile                       :
  OsProfile                                 :
    ComputerNamePrefix                      : test
    AdminUsername                           : contoso
    WindowsConfiguration                    :
      ProvisionVMAgent                      : True
      EnableAutomaticUpdates                : True
  StorageProfile                            :
    ImageReference                          :
      Publisher                             : MicrosoftWindowsServer
      Offer                                 : WindowsServer
      Sku                                   : 2016-Datacenter
      Version                               : latest
    OsDisk                                  :
      Caching                               : None
      CreateOption                          : FromImage
      ManagedDisk                           :
        StorageAccountType                  : Premium_LRS
  NetworkProfile                            :
    NetworkInterfaceConfigurations[0]       :
      Name                                  : Group001
      Primary                               : True
      EnableAcceleratedNetworking           : False
      NetworkSecurityGroup                  :
        Id                                  : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/Group001
/providers/Microsoft.Network/networkSecurityGroups/Group001
      DnsSettings                           :
      IpConfigurations[0]                   :
        Name                                : Group001
        Subnet                              :
          Id                                : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/group001
/providers/Microsoft.Network/virtualNetworks/Group001/subnets/Group001
        PrivateIPAddressVersion             : IPv4
        LoadBalancerBackendAddressPools[0]  :
          Id                                : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/group001
/providers/Microsoft.Network/loadBalancers/Group001/backendAddressPools/Group001
        LoadBalancerInboundNatPools[0]      :
          Id                                : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/group001
/providers/Microsoft.Network/loadBalancers/Group001/inboundNatPools/Group001
        LoadBalancerInboundNatPools[1]      :
          Id                                : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/group001
/providers/Microsoft.Network/loadBalancers/Group001/inboundNatPools/Group001
      EnableIPForwarding                    : False
ProvisioningState                           : Succeeded
Overprovision                               : True
UniqueId                                    : xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
SinglePlacementGroup                        : False
Id                                          : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/Group001/
providers/Microsoft.Compute/virtualMachineScaleSets/VMSS001
Name                                        : VMSS001
Type                                        : Microsoft.Compute/virtualMachineScaleSets
Location                                    : eastus
Tags                                        : {}

此命令获取属于名为 Group001 的资源组VMSS001的 VMSS 的属性。 由于命令未指定 InstanceView 开关参数,因此 cmdlet 获取虚拟机规模集的模型视图。

示例 2:获取资源组中的所有 Vm

Get-AzVmss -ResourceGroupName "Group001"

ResourceGroupName                               Name       Location             Sku Capacity ProvisioningState
-----------------                               ----       --------             --- -------- -----------------
Group001                                       VMSS001      eastus Standard_DS1_v2        2         Succeeded
Group001                                       VMSS002      eastus     Standard_A1        2         Succeeded

获取资源组“Group001”中的所有 Vms

示例 3:获取订阅中的所有 VM

Get-AzVmss

ResourceGroupName                               Name       Location             Sku Capacity ProvisioningState
-----------------                               ----       --------             --- -------- -----------------
Group001                                       VMSS001      eastus Standard_DS1_v2        2         Succeeded
Group001                                       VMSS002      eastus     Standard_A1        2         Succeeded
Group002                                       VMSS003      eastus     Standard_A1        1         Succeeded
Group002                                       VMSS004      eastus Standard_DS1_v2        2         Succeeded

获取订阅中的所有 Vmss。

示例 4:使用筛选获取所有 Vm

Get-AzVmss -Name VMSS00*

ResourceGroupName                               Name       Location             Sku Capacity ProvisioningState
-----------------                               ----       --------             --- -------- -----------------
Group001                                       VMSS001      eastus Standard_DS1_v2        2         Succeeded
Group001                                       VMSS002      eastus     Standard_A1        2         Succeeded
Group002                                       VMSS003      eastus     Standard_A1        1         Succeeded
Group002                                       VMSS004      eastus Standard_DS1_v2        2         Succeeded

获取以“VMSS00”开头的订阅中的所有 Vmss。

示例 5:获取具有 UserData 值的 Vmss

Get-AzVmss -ResourceGroupName <RESOURCE GROUP NAME> -VMScaleSetName <VMSS NAME> -InstanceView:$false -UserData;

ResourceGroupName                           : <RESOURCE GROUP NAME>
Sku                                         :
  Name                                      : Standard_DS1_v2
  Tier                                      : Standard
  Capacity                                  : 2
UpgradePolicy                               :
  Mode                                      : Manual
ProvisioningState                           : Succeeded
Overprovision                               : True
DoNotRunExtensionsOnOverprovisionedVMs      : False
UniqueId                                    : <UNIQUE ID>
SinglePlacementGroup                        : False
Id                                          : /subscriptions/<SUBSCRIPTION ID>/resourceGroups/<RESOURCE GROUP NAME>/providers/Microsoft.Compute/virtualMachineScaleSets/<VMSS NAME>
Name                                        : usdvmss
Type                                        : Microsoft.Compute/virtualMachineScaleSets
Location                                    : eastus
Tags                                        :
{"azsecpack":"nonprod","platformsettings.host_environment.service.platform_optedin_for_rootcerts":"true"}
VirtualMachineProfile                       :
  OsProfile                                 :
    ComputerNamePrefix                      : <PREFIX>
    AdminUsername                           : <USERNAME>
    WindowsConfiguration                    :
      ProvisionVMAgent                      : True
      EnableAutomaticUpdates                : True
  StorageProfile                            :
    ImageReference                          :
      Publisher                             : MicrosoftWindowsServer
      Offer                                 : WindowsServer
      Sku                                   : 2016-Datacenter
      Version                               : latest
    OsDisk                                  :
      Caching                               : None
      CreateOption                          : FromImage
      DiskSizeGB                            : 127
      OsType                                : Windows
      ManagedDisk                           :
        StorageAccountType                  : Premium_LRS
  NetworkProfile                            :
    NetworkInterfaceConfigurations[0]       :
      Name                                  : <VMSS NAME>
      Primary                               : True
      EnableAcceleratedNetworking           : False
      DnsSettings                           :
      IpConfigurations[0]                   :
        Name                                : <VMSS NAME>
        Subnet                              :
          Id                                : /subscriptions/<SUBSCRIPTION ID>/resourceGroups/<RESOURCE GROUP NAME>/providers/Microsoft.Network/virtualNetworks/<VMSS NAME>/subnets/<VMSS NAME>
        PrivateIPAddressVersion             : IPv4
        LoadBalancerBackendAddressPools[0]  :
          Id                                : /subscriptions/<SUBSCRIPTION ID>/resourceGroups/<RESOURCE GROUP NAME>/providers/Microsoft.Network/loadBalancers/<VMSS NAME>/backendAddressPools/<VMSS NAME>
        LoadBalancerInboundNatPools[0]      :
          Id                                : /subscriptions/<SUBSCRIPTION ID>/resourceGroups/<RESOURCE GROUP NAME>/providers/Microsoft.Network/loadBalancers/<VMSS NAME>/inboundNatPools/<VMSS NAME>
        LoadBalancerInboundNatPools[1]      :
          Id                                : /subscriptions/<SUBSCRIPTION ID>/resourceGroups/<RESOURCE GROUP NAME>/providers/Microsoft.Network/loadBalancers/<VMSS NAME>/inboundNatPools/<VMSS NAME>
      EnableIPForwarding                    : False
  ExtensionProfile                          :
    Extensions[0]                           :
      Name                                  : Microsoft.Azure.Security.AntimalwareSignature.AntimalwareConfiguration
      Publisher                             : Microsoft.Azure.Security.AntimalwareSignature
      Type                                  : AntimalwareConfiguration
      TypeHandlerVersion                    : 2.0
      AutoUpgradeMinorVersion               : True
      EnableAutomaticUpgrade                : True
      Settings                              : {}
    Extensions[1]                           :
      Name                                  : Microsoft.Azure.Geneva.GenevaMonitoring
      Publisher                             : Microsoft.Azure.Geneva
      Type                                  : GenevaMonitoring
      TypeHandlerVersion                    : 2.0
      AutoUpgradeMinorVersion               : True
      EnableAutomaticUpgrade                : True
      Settings                              : {}
  UserData                                  : dQBwAGQAYQB0AGUAIAB2AG0AcwBzAA==

UserData 值必须经过 Base64 编码。 此命令假定已创建具有 UserData 值的 Vmss。

示例 6:通过其 ResourceId 获取虚拟机规模集。

$rgname = "ResourceGroupName";
$loc = "eastus";
New-AzResourceGroup -Name $rgname -Location $loc;

$vmssSize = 'Standard_D4s_v3';
$vmssName1 = 'vmss1' + $rgname;
$imageName = "Win2019Datacenter";
$adminUsername = <Username>;
$adminPassword = ConvertTo-SecureString -String "****" -AsPlainText -Force;
$cred = New-Object System.Management.Automation.PSCredential($adminUsername, $adminPassword);

$result = New-AzVmss -ResourceGroupName $rgname -Credential $cred -VMScaleSetName $vmssName1 -ImageName $imageName;

$vmss = Get-AzVmss -ResourceGroupName $rgname -VMScaleSetName $vmssName1;
$vmssId = $vmss.Id;
$vmssGet = Get-AzVmss -ResourceId $vmssId;

创建 Vm,然后通过其 ARM 资源 ID 获取相同的 Vm。

参数

-DefaultProfile

用于与 Azure 通信的凭据、帐户、租户和订阅。

类型:IAzureContextContainer
别名:AzContext, AzureRmContext, AzureCredential
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-InstanceView

指示此 cmdlet 仅获取虚拟机规模集的实例视图。

类型:SwitchParameter
Position:Named
默认值:None
必需:True
接受管道输入:False
接受通配符:False

-OSUpgradeHistory

指示此 cmdlet 列出了虚拟机规模集的 OS 升级历史记录。

类型:SwitchParameter
Position:Named
默认值:None
必需:True
接受管道输入:False
接受通配符:False

-ResourceGroupName

指定 VMSS 的资源组的名称。

类型:String
Position:0
默认值:None
必需:False
接受管道输入:True
接受通配符:True

-ResourceId

用于指定要返回的特定虚拟机规模集对象的 ARM 资源 ID。

类型:String
Position:Named
默认值:None
必需:False
接受管道输入:True
接受通配符:False

-UserData

Vmss 的 UserData(将进行 base-64 编码)。 客户不应在此处传递任何机密。

类型:SwitchParameter
Position:Named
默认值:None
必需:False
接受管道输入:True
接受通配符:False

-VMScaleSetName

为 VMSS 的名称命名。

类型:String
别名:Name
Position:1
默认值:None
必需:False
接受管道输入:True
接受通配符:True

输入

String

输出

PSVirtualMachineScaleSet