# encoding: ascii
# api: powershell
# title: VM Disk Report
# description: Gets all Virtual Machines, and exports a CSV that shows their virtual disk capacities and type. Used in this case for sizing a VCB temp disk.
# version: 0.1
# type: script
# author: jgrote
# license: CC0
# x-poshcode-id: 5148
# x-archived: 2014-05-15T05:10:01
# x-published: 2014-05-06T04:06:00
#
#
$VMs = get-vm
$Results = @()
foreach ($VM in $VMs) {
    $Result = new-object PSObject
    $Result | add-member -membertype NoteProperty -name "Name" -value $VM.Name
    $Result | add-member -membertype NoteProperty -name "Description" -value $VM.Notes
    $VMDiskCount = 1
    get-harddisk $VM | foreach {
        $disk = $_
        $Result | add-member -name "Disk($VMDiskCount)SizeGB" -value ([math]::Round($disk.CapacityKB / 1MB)) -membertype NoteProperty
        $Result | add-member -name "Disk($VMDiskCount)Type" -value $disk.DiskType -membertype NoteProperty
        $VMDiskCount++
    }
    $Results += $Result
}
$Results | select-object * | export-csv -notypeinformation E:\VCBDiskReport.csv
