Retrieving Virtual Machine Hosts

Retrieves the specified Virtual Machine Host object(s).


Examples:


Hint: The execution of these examples requires a connected PowerShell drive.


Retrieve the VM-Host "XenSrv01" from the Organizational Unit "XenServers":


Get-EmdbVirtualHost "emdb:\rootDSE\Managed Virtual Environments\XenServers\XenSrv01"


Retrieve all VM-Hosts from the Organizational Unit "ESXServers":


Get-EmdbVirtualHost "emdb:\rootDSE\Managed Virtual Environments\ESXServers\*"


Retrieve all VM-Hosts having their names starting with the substring "ESX" from "Virtual Environments" and subordinated Organizational Units:


Get-EmdbVirtualHost "emdb:\rootDSE\Managed Virtual Environments\ESX*" -Recurse


Retrieve the VM-Host "HVSRV01" from the current context:


Cd "emdb:\rootDSE\Managed Virtual Environments\Hyper-V Hosts"

Get-EmdbVirtualHost "HVSRV01"


Retrieve the VM-Host "SRVHYP01" in the current context through its Item-ID (this ID will vary in different DSM environments):


Get-EmdbVirtualHost -ItemID 1452 -Recurse


Tip: the alias ID can be used instead of ItemID.


Retrieve the VM-Host "ESXSRV1" from the current context using the cmdlet Get-Item:


Cd "emdb:\rootDSE\Managed Virtual Environments\ESXServers"

Get-Item "ESXSRV1"


Retrieve all VM-Hosts having their names starting with the substring "Xen" from "XenServers" and subordinated Organizational Units using the cmdlet Get-ChildItem:


Get-ChildItem "emdb:\rootDSE\Managed Virtual Environments\XenServers" -Filter "&(Name=Xen*)(SchemaTag=VMHost)" -Recurse


Starting with PSX 3.1 there was a new option implemented when retrieving Virtual Machine Host objects. When specifying the SingleItemExpected-switch it is expected, that none or exactly one object is contained in the result. If the retrieval returns more than one object, an error is raised that can be caught and handled in scripts.