Hi,
I am having the below script, I would like to get the clustername. but I am getting the error
Please help!!
$report = Get-Template | Select @{N="Folder_Name";E={(Get-View -Id $_.ExtensionData.Parent -Property Name).Name}},
@{N="Cluster";E={(Get-VMhost -id $_.HostID).Name.Parent}},
@{N="Host";E={(Get-VMhost -id $_.HostID).Name}},
@{N="Template_Name";E={$_.Name}},
@{N="vCPU";E={$_.ExtensionData.Config.Hardware.NumCPU}},
@{N="Memory(GB)";E={$_.ExtensionData.Config.Hardware.MemoryMB/1024}},
@{N="HDD(GB)";E={($_ | Get-HardDisk | Measure-Object -Sum CapacityGB).Sum}},
@{N="OS";E={$_.ExtensionData.Config.GuestFullName}},
@{N="Port Group";E={(Get-view -Id $_.ExtensionData.Network).Name}},
@{N="Datastore"; E={(Get-Datastore -id $_.DatastoreIDlist).Name -join ","}},
@{N='VMTX';E={$_.extensiondata.config.files.VmPathName}}
$sum = $report | Measure-Object -sum "vCPU", "Memory(GB)", "HDD(GB)"
$row1 = "" | Select "Folder_Name",Cluster,"Template_Name","vCPU", "Memory(GB)", "HDD(GB)"
$report += $row1
$row2 = "" | Select "Folder_Name",Cluster,"Template_Name","vCPU", "Memory(GB)", "HDD(GB)"
$row2."Folder_Name" = 'Total'
$row2."Template_Name" = (Get-Template).count
$row2.vCPU = $sum | where{$_.Property -eq 'vCPU'} | select -ExpandProperty Sum
$row2."Memory(GB)" = $sum | where{$_.Property -eq "Memory(GB)"} | select -ExpandProperty Sum
$row2."HDD(GB)" = $sum | where{$_.Property -eq "HDD(GB)"} | select -ExpandProperty Sum
$report += $row2
$report