PoshCode Archive  Artifact Content

Artifact b916e3ae3da578e3e44e8a3e9aab60581c3a36f06d5daddafa00619b910ca2d5:

  • File VM-Disk-Report.ps1 — part of check-in [307cdfb3b7] at 2018-06-10 13:02:50 on branch trunk — 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. (user: unknown size: 1080)

# 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
# license: CC0
# x-poshcode-id: 1925
# x-derived-from-id: 1933
# x-archived: 2011-01-17T07:46:55
#
#

$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