共用方式為


Get-AzureRmVM

取得虛擬機器的屬性。

警告

自 2024 年 2 月 29 日起,AzureRM PowerShell 模組已正式淘汰。 建議使用者從 AzureRM 遷移至 Az PowerShell 模組,以確保持續支援和更新。

雖然 AzureRM 模組可能仍可運作,但不再維護或支援它,但會根據用戶的判斷權和風險放置任何繼續使用。 如需轉換至 Az 模組的指引,請參閱我們的 移轉資源

語法

Get-AzureRmVM
   [-Status]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Get-AzureRmVM
   [-ResourceGroupName] <String>
   [-Status]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Get-AzureRmVM
   [-ResourceGroupName] <String>
   [-Name] <String>
   [-Status]
   [-DisplayHint <DisplayHintType>]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Get-AzureRmVM
   -Location <String>
   [-Status]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Get-AzureRmVM
   [-Status]
   [-NextLink] <Uri>
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]

Description

Get-AzureRmVM Cmdlet 會取得 Azure 虛擬機的模型檢視和實例檢視。 模型檢視是虛擬機的使用者指定屬性。 實例檢視是虛擬機的實例層級狀態。 指定 Status 參數,只取得虛擬機的實例檢視。

範例

範例 1:取得模型和實例檢視屬性

PS C:\> Get-AzureRmVM -ResourceGroupName "ResourceGroup11" -Name "VirtualMachine07"

此命令會取得名為 VirtualMachine07 之虛擬機的模型檢視和實例檢視屬性。

範例 2:取得實例檢視屬性

PS C:\> Get-AzureRmVM -ResourceGroupName "ResourceGroup11" -Name "VirtualMachine07" -Status

此命令會取得名為 VirtualMachine07 的虛擬機屬性。 此命令會 指定 Status 參數。 因此,命令只會取得實例檢視屬性。

範例 3:取得資源群組中所有虛擬機的屬性

PS C:\> Get-AzureRmVM -ResourceGroupName "ResourceGroup11"

此命令會取得資源群組中名為 ResourceGroup11 之所有虛擬機的屬性。

範例 4:取得訂用帳戶中的所有虛擬機

PS C:\> Get-AzureRmVM

此命令會取得訂用帳戶中的所有虛擬機。

範例 5:取得位置中的所有虛擬機。

PS C:\> Get-AzureRmVM -Location "westus"

此命令會取得美國西部區域的所有虛擬機。

參數

-DefaultProfile

用於與 azure 通訊的認證、帳戶、租用戶和訂用帳戶。

類型:IAzureContextContainer
別名:AzureRmContext, AzureCredential
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-DisplayHint

決定虛擬機對象的顯示方式。 有效值為: -- Compact: 只顯示最上層屬性 -- 展開:顯示所有層級中的所有屬性

類型:DisplayHintType
接受的值:Compact, Expand
Position:Named
預設值:None
必要:False
接受管線輸入:True
接受萬用字元:False

-Location

指定要列出之虛擬機的位置。

類型:String
Position:Named
預設值:None
必要:True
接受管線輸入:True
接受萬用字元:False

-Name

指定要取得的虛擬機名稱。

類型:String
別名:ResourceName, VMName
Position:1
預設值:None
必要:True
接受管線輸入:True
接受萬用字元:False

指定下一個連結。

類型:Uri
Position:1
預設值:None
必要:True
接受管線輸入:True
接受萬用字元:False

-ResourceGroupName

指定資源群組的名稱。

類型:String
Position:0
預設值:None
必要:True
接受管線輸入:True
接受萬用字元:False

-Status

指出此 Cmdlet 只會取得虛擬機的實例檢視。

類型:SwitchParameter
Position:2
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

輸入

String

Uri

DisplayHintType

輸出

PSVirtualMachine

PSVirtualMachineInstanceView