VMware Cloud Community
hemadri18
Contributor
Contributor

issues in accessing VMHost from get-VM

Plz help

I am facing a following issues

Get-VM -server IP Address |select-object VMHost | Foreach-object{ write-output $_.VMHost}

print the entire VM infor instead of just VMHost

PowerState              : PoweredOn

Version                 : v8

Description             :

Notes                   :

Guest                   : SUSE LINUX 11.2 64 bit:

NumCpu                  : 1

MemoryMB                : 2048

MemoryGB                : 2

HardDisks               : {Hard disk 1}

NetworkAdapters         : {Network adapter 1, Network adapter 2}

UsbDevices              : {}

CDDrives                : {CD/DVD drive 1}

FloppyDrives            : {Floppy drive 1}

Host                    :

HostId                  :

VMHostId                :

VMHost                  :

VApp                    :

FolderId                : Folder-group-v9

Folder                  : Discovered virtual machine

ResourcePoolId          : ResourcePool-resgroup-8

ResourcePool            : Resources

PersistentId            :

UsedSpaceGB             :

ProvisionedSpaceGB      :

DatastoreIdList         : {Datastore-datastore-123}

HARestartPriority       : ClusterRestartPriority

HAIsolationResponse     : AsSpecifiedByCluster

DrsAutomationLevel      : AsSpecifiedByCluster

VMSwapfilePolicy        : Inherit

VMResourceConfiguration : CpuShares:Normal/1000 MemShares:Normal/40960

Name                    : t

CustomFields            : {}

ExtensionData           : VMware.Vim.VirtualMachine

Id                      :

Uid                     :

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership

Try like this

Get-VM -server IP Address | Select Name,@{N="Host";E={$_.Host.Name}}

The Select uses a calculated property to just return the name of the host to which the VM belongs


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
hemadri18
Contributor
Contributor

Its still not working..

Is $_.Host.Name is correct ? or should I try $_.VMHost instead ?

Reply
0 Kudos
Chrigoli
Enthusiast
Enthusiast

I would try with $_.VMHost.

According to the documentation, .Host.Name is deprecated as of PowerCLI 5.0.

vSphere 5.5 Documentation Center

Reply
0 Kudos
Dragonfly26
Contributor
Contributor

What is the error your getting?

have you tried: 

Get-VM -Server IP Address | select Name , Host

Reply
0 Kudos