Search code examples
powershellvmwarevsphereesxihypervisor

PowerShell: How to get the name of my ESXi


How to get the ESXI Name? what I tried:

Add-PsSnapin VMware.VimAutomation.Core -ErrorAction  "SilentlyContinue"
$User = 
$Password = 
$ESXiServer = "IPAddress"
Connect-VIServer $ESXiServer -User $User -Password $Password 

$Datacenter = Get-Datacenter
$Datastore = Get-Datastore
$DataStoreLocation = $Datastore.ExtensionData.info.url  
$Datastore = Get-Datastore

"get-vm" gives me the VMs which are on m Hyper-V.
"get-vmhost" gives me the name of my Computer.

I do not know how to get the name of my ESXI server!!

EDIT:

found a command which gives me ESXi name but do not know how to extract just the "name" Information

Get-MvmcSourceVirtualMachine -SourceConnection $sourceConnection 

Solution

  • I could get my ESXi name by this command:

    (Get-MvmcSourceVirtualMachine -SourceConnection $sourceconnection).Name