Get-AzVmss
語法
DefaultParameter (預設值)
Get-AzVmss
[[-ResourceGroupName] <String>]
[[-VMScaleSetName] <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
FriendMethod
Get-AzVmss
[[-ResourceGroupName] <String>]
[[-VMScaleSetName] <String>]
[-InstanceView]
[-UserData]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
OSUpgradeHistoryMethodParameter
Get-AzVmss
[[-ResourceGroupName] <String>]
[[-VMScaleSetName] <String>]
[-OSUpgradeHistory]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
ResourceIdParameterSet
Get-AzVmss
[-ResourceId <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Description
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 : {}
此命令會取得名為 VMSS001 的 VMSS 屬性,該屬性屬於名為 Group001 的資源群組。
由於命令未指定 InstanceView 參數,因此 Cmdlet 會取得虛擬機器擴展集的模型檢視。
範例 2:取得資源群組中的所有虛擬機器
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」 中的所有虛擬機器
範例 3:取得訂用帳戶中的所有虛擬機器
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:使用篩選取得所有虛擬機器
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」開頭的所有 Vms。
範例 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;
建立 Vmss,然後透過其 ARM 資源識別碼取得相同的 Vmss。
參數
-DefaultProfile
用於與 azure 通訊的認證、帳戶、租用戶和訂用帳戶。
參數屬性
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-InstanceView
表示此 Cmdlet 只會取得虛擬機器擴展集的執行個體檢視。
參數屬性
參數集
FriendMethod
| Position: | Named |
| 必要: | True |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-OSUpgradeHistory
指出此 Cmdlet 會列出虛擬機器擴展集的 OS 升級歷程記錄。
參數屬性
參數集
OSUpgradeHistoryMethodParameter
| Position: | Named |
| 必要: | True |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-ResourceGroupName
指定 VMSS 的資源群組名稱。
參數屬性
| 類型: | String
|
| 預設值: | None |
| 支援萬用字元: | True |
| 不要顯示: | False |
參數集
DefaultParameter
| Position: | 0 |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
FriendMethod
| Position: | 0 |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
OSUpgradeHistoryMethodParameter
| Position: | 0 |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
-ResourceId
指定您要傳回的特定虛擬機器擴展集物件的 ARM 資源識別碼。
參數屬性
| 類型: | String
|
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
ResourceIdParameterSet
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
-UserData
UserData 的 Vmss,將以 base-64 編碼。 客戶不應在此傳遞任何秘密。
參數屬性
參數集
FriendMethod
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
-VMScaleSetName
物種 VMSS 的名稱。
參數屬性
| 類型: | String
|
| 預設值: | None |
| 支援萬用字元: | True |
| 不要顯示: | False |
| 別名: | 名稱 |
參數集
DefaultParameter
| Position: | 1 |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
FriendMethod
| Position: | 1 |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
OSUpgradeHistoryMethodParameter
| Position: | 1 |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
CommonParameters
此 cmdlet 支援常見參數:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 如需詳細資訊,請參閱 about_CommonParameters。
輸出