Created
September 5, 2016 23:24
-
-
Save davelee212/ebc59dc68f0f7d4655e03f6f83c9bc74 to your computer and use it in GitHub Desktop.
vcd-vm-listings.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-VDCVMDetails { | |
# Adapted from original code from http://geekafterfive.com/2013/03/21/simple-vm-reporting-in-vcloud-with-powercli/ | |
# Added MAC Address, Network Connection, Storage Profile and setup as a function | |
$objects = @() | |
$vms = $input | Get-CIVM | |
foreach($vm in $vms) | |
{ | |
$hardware = $vm.ExtensionData.GetVirtualHardwareSection() | |
$diskMB = (($hardware.Item | where {$_.resourcetype.value -eq "17"}) | %{$_.hostresource[0].anyattr[0]."#text"} | Measure-Object -Sum).sum | |
$primaryMACAddress = ($hardware.Item | where {$_.resourcetype.value -eq "10"}).Address.value.ToString() | |
$primaryNetConn = ($hardware.Item | where {$_.resourcetype.value -eq "10"}).connection.value.ToString() | |
$row = New-Object PSObject -Property @{ ` | |
"vapp" = $vm.vapp; ` | |
"name"=$vm.Name; ` | |
"guestos"=$vm.GuestOSFullName; ` | |
"Status"=$vm.Status; ` | |
"cpuCount"=$vm.CpuCount; ` | |
"memoryGB"=$vm.MemoryGB; ` | |
"primaryMACAddress"=$primaryMACAddress; ` | |
"primaryNetConn"=$primaryNetConn; ` | |
"storageGB"=($diskMB/1024); ` | |
"storageProfile"=$vm.ExtensionData.storageProfile.name; | |
} | |
$objects += $row | |
} | |
# Use select object to get the column order right. Sort by vApp. Force table formatting and auto-width. | |
$objects | select-Object name,status,vapp,guestos,cpuCount,memoryGB,primaryMACAddress,primaryNetConn,storageGB,storageProfile | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment