PoshCode Archive  Artifact Content

Artifact d9102c92187d5fed01b8f28025c0e06723fbd7fdb6c68f7c45f44b3d6a72851d:

  • File VM-Disk-Report.ps1 — part of check-in [6b9bd5ea5a] at 2018-06-10 13:03:00 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: jgrote size: 1069)

# 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: 1933
# x-archived: 2011-01-17T07:47:44
#
#
$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