VMware Cloud Community
GAPCABIV
Enthusiast
Enthusiast
Jump to solution

VMHost info not exporting

Here is an oddball issue I am facing.  I have an older server with PowerCLI 5.1 which when I run the below script will output info about the VMs running on all my hosts.  When I run the same script from PowerCLI 6.3 I get almost all the info but not the VMHost info in my out put.

Example of output from 5.1:

"Name","IPAddress","MemoryMB","NumCpu","Cores","Provisionedspace(GB)","VMHost"

"myvm01","10.10.10.9","2048","1","1","42","esx01"

"myvm02","10.10.10.15","12288","6","1","67","esx01"

etc

Example of output from 6.3:

"Name","IPAddress","MemoryMB","NumCpu","Cores","Provisionedspace(GB)","VMHost"

"myvm01","10.10.10.9","2048","1","1","42",

"myvm02","10.10.10.15","12288","6","1","67",

In addition to not getting the VMHost info, it seems to take about 10 minutes to put together the full output into a CSV in 6.3 but in 5.1 it takes perhaps 30 seconds or so.  If I change "VMHost" to just "Host" on 6.3 I get the output just as fast as with 5.1 but still the "Host" info is not present in my output.

Script is below.  Any suggestions host to get the host info added with 6.3?

#Get List Of All ESXi Hosts

$hosts = @(

  "esx01",

  "esx02",

  "esx03",

  "esx04",

  "esx05",

  "esx06",

  "esx07",

  "esx08",

  "inf03",

  "inf04",

  "esxi01",

  "esxorcl"

);

$vmtotals = @()

ForEach ($host222 in $hosts){

#CONNECT TO VCENTER SERVER

connect-viserver -server $host222 -Protocol https -User root -Password ThisIsNotMyRealPassword

#Get Inventory Details

$vms = Get-VM | select Name, @{N="IPAddress"; E={$_.Guest.IPAddress[0]}}, MemoryMB, NumCPU, @{N="Cores"; E={$_.ExtensionData.config.hardware.NumCoresPerSocket}}, @{n="Provisionedspace(GB)"; E={[math]::round($_.ProvisionedSpaceGB)}}, VMHost

$vmtotals += $vms

#DISCONNECT FROM VCENTER SERVER

disconnect-viserver -confirm:$false

}

$vmtotals | Export-Csv -path "\\reportserver\Reports\VMware\Vmware_Inventory.csv" -NoTypeInformation

0 Kudos
1 Solution

Accepted Solutions
GAPCABIV
Enthusiast
Enthusiast
Jump to solution

I just discovered that replacing VMHost with @{N="VMHost"; E={$_.VMHost.Name}} give me the desired results.

This question is answered

View solution in original post

0 Kudos
1 Reply
GAPCABIV
Enthusiast
Enthusiast
Jump to solution

I just discovered that replacing VMHost with @{N="VMHost"; E={$_.VMHost.Name}} give me the desired results.

This question is answered

0 Kudos