共用方式為


Get-SCVirtualMachine

獲取虛擬機物件。

語法

Get-SCVirtualMachine
   [-VMMServer <ServerConnection>]
   [[-Name] <String>]
   [-All]
   [-OnBehalfOfUser <String>]
   [-OnBehalfOfUserRole <UserRole>]
   [<CommonParameters>]
Get-SCVirtualMachine
   -VMHost <Host>
   [-VMMServer <ServerConnection>]
   [[-Name] <String>]
   [-OnBehalfOfUser <String>]
   [-OnBehalfOfUserRole <UserRole>]
   [<CommonParameters>]
Get-SCVirtualMachine
   [-VMMServer <ServerConnection>]
   -Cloud <Cloud>
   [[-Name] <String>]
   [-OnBehalfOfUser <String>]
   [-OnBehalfOfUserRole <UserRole>]
   [<CommonParameters>]
Get-SCVirtualMachine
   [-VMMServer <ServerConnection>]
   -Service <Service>
   [[-Name] <String>]
   [-OnBehalfOfUser <String>]
   [-OnBehalfOfUserRole <UserRole>]
   [<CommonParameters>]
Get-SCVirtualMachine
   [-VMMServer <ServerConnection>]
   -ComputerTier <ComputerTier>
   [[-Name] <String>]
   [-OnBehalfOfUser <String>]
   [-OnBehalfOfUserRole <UserRole>]
   [<CommonParameters>]
Get-SCVirtualMachine
   [-VMMServer <ServerConnection>]
   -StorageQoSPolicy <StorageQoSPolicy>
   [[-Name] <String>]
   [-OnBehalfOfUser <String>]
   [-OnBehalfOfUserRole <UserRole>]
   [<CommonParameters>]
Get-SCVirtualMachine
   [-VMMServer <ServerConnection>]
   [[-Name] <String>]
   [-ID <Guid>]
   [-OnBehalfOfUser <String>]
   [-OnBehalfOfUserRole <UserRole>]
   [<CommonParameters>]

Description

Get-SCVirtualMachine cmdlet 從 Virtual Machine Manager (VMM) 資料庫中獲取一個或多個虛擬機物件。 此 cmdlet 獲取部署在虛擬主機上或存儲在 VMM 庫中的虛擬機。

範例

範例 1:獲取所有虛擬機並顯示有關每個虛擬機器的資訊

PS C:\> Get-SCVirtualMachine -VMMServer "VMMServer01.Contoso.com"

此命令獲取 VMMServer01 上的所有虛擬機物件,並顯示有關這些虛擬機物件的資訊。

範例 2:獲取所有虛擬機並顯示有關特定屬性的資訊

PS C:\> Get-SCVirtualMachine -VMMServer "VMMServer01.Contoso.com" | Format-List -Property Name, Owner, Description, HostName, OperatingSystem, CPUCount, Memory

此命令獲取 VMMServer01 上的所有虛擬機物件,並顯示指定屬性的值。

範例 3:按名稱獲取存儲在指定庫伺服器上的虛擬機

PS C:\> Get-SCVMMServer -ComputerName "VMMServer01.Contoso.com"
PS C:\> Get-SCVirtualMachine | Where-Object { $_.Name -Eq "VM02" -And $_.LibraryServer -Eq "LibraryServer01" } | Select-Object Name,LibraryServer,Status

第一個命令連接到 VMMServer01。

第二個命令獲取存儲在 LibraryServer01 上的名為 VM02 的虛擬機對象,然後顯示虛擬機名稱、庫伺服器的名稱和虛擬機的狀態。

範例 4:獲取指定主機上的所有虛擬機

PS C:\> Get-SCVMMServer -ComputerName "VMMServer01.Contoso.com"
PS C:\> Get-SCVirtualMachine -VMHost "VMHost01.Contoso.com"

第一個命令連接到 VMMServer01。

第二個命令獲取在 VMHost01 上部署的所有虛擬機物件,並顯示有關這些虛擬機的資訊。

參數

-All

指示此 cmdlet 獲取獨立於父物件的所有從屬物件。 例如,該命令 Get-SCVirtualDiskDrive -All 將獲取所有虛擬磁碟驅動器物件,而不管每個虛擬磁碟驅動器對象與哪個虛擬機物件或範本物件相關聯。

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

-Cloud

指定私有雲物件。

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

-ComputerTier

指定計算機層物件。

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

-ID

指定物件的唯一 ID。

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

-Name

指定 VMM 物件的名稱。

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

-OnBehalfOfUser

指定用戶名稱。 此 cmdlet 代表此參數指定的用戶進行作。

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

-OnBehalfOfUserRole

指定使用者角色。 若要獲取使用者角色,請使用 Get-SCUserRole cmdlet。 此 cmdlet 代表此參數指定的使用者角色進行作。

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

-Service

指定 VMM 服務物件。

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

-StorageQoSPolicy

指定此 cmdlet 獲取的虛擬機的服務品質 (QoS) 策略。

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

-VMHost

指定虛擬機主機物件。 VMM 支援 Hyper-V 主機、VMware ESX 主機和 Citrix XenServer 主機。

有關每種類型的主機的詳細資訊,請參閱 Add-SCVMHost cmdlet。

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

-VMMServer

指定 VMM 伺服器物件。

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

輸出

VirtualMachine

此 cmdlet 返回 VirtualMachine 物件。