2

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 
frhling1
  • 55
  • 1
  • 6
  • 11

2 Answers2

0

get-vmhost returns ESXi server object information
(get-vmhost ($global:DefaultVIServer).name )).extensiondata.name should give you the esxi server name

Sergei
  • 387
  • 1
  • 6
  • 16
  • The result is an IPaddress which is the same as : $ESXiServer = "IPAddress" – frhling1 Jun 30 '16 at 10:23
  • how about (get-vmhost ($global:DefaultVIServer).name )).extentiondata.name – Sergei Jun 30 '16 at 10:47
  • mine is in german. I have translated for you: get-vmhost : Mindestens ein Fehler ist aufgetreten. In Zeile:1 Zeichen:2 + (get-vmhost ($global:DefaultVIServer).name ).extentiondata.name + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Get-VMHost], VirtualizationException + FullyQualifiedErrorId : Unspecified,Microsoft.HyperV.PowerShell.Commands.GetVMHost . at least there is an Error is translation of Mindestens ein Fehler ist aufgetreten. – frhling1 Jun 30 '16 at 11:09
  • there was a typo in my reply - 'extention' instead of 'extension' – Sergei Jun 30 '16 at 11:19
  • same Error: get-vmhost : Mindestens ein Fehler ist aufgetreten. In Zeile:1 Zeichen:2 + (get-vmhost ($global:DefaultVIServer).name ).ExtentionData.name + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Get-VMHost], VirtualizationException + FullyQualifiedErrorId : Unspecified,Microsoft.HyperV.PowerShell.Commands.GetVMHost – frhling1 Jun 30 '16 at 11:21
  • you did not change the command "($global:DefaultVIServer).name ).ExtentionData.name" – Sergei Jun 30 '16 at 11:25
  • "(($global:DefaultVIServer).name ).ExtentionData.name" is empty. gives me no result! – frhling1 Jun 30 '16 at 11:29
  • Please use extenSiondata – Sergei Jun 30 '16 at 11:52
  • "(($global:DefaultVIServer).name ).extenSiondata.name" gives me also no result – frhling1 Jun 30 '16 at 11:54
  • Can you see the output of (get-vmhost ($global:DefaultVIServer).name )).extensiondata ? – Sergei Jun 30 '16 at 12:14
  • no. It has Error. I have edited my question. can you please Check. – frhling1 Jun 30 '16 at 12:23
  • it would be helpful to describe the environment you use. Get-MvmcSourceVirtualMachine is virtual machine conversion cmdlet. – Sergei Jun 30 '16 at 12:29
  • Thats why I need the VM(ESXi) name. when i run this command: Get-MvmcSourceVirtualMachine -SourceConnection $sourceConnection i can see its name. but do not know how to extract the name – frhling1 Jul 01 '16 at 07:32
0

I could get my ESXi name by this command:

(Get-MvmcSourceVirtualMachine -SourceConnection $sourceconnection).Name
frhling1
  • 55
  • 1
  • 6
  • 11