PowerCLI – VM Guest Disk Sizes

A oneline script to show the VM disk (or partiton) for each of your VM’s:

Or look at the “advanced” script of virtu-al (http://www.virtu-al.net/2010/01/27/powercli-virtual-machine-disk-usage/)

3 Comments

  1. HI, i try save output to csv file with export-csv command and it’s fails.

    An empty pipe element is not allowed.
    At line:1 char:313
    + ForEach ($VM in (Get-VM |Get-View)){($VM.Guest.Disk |Select @{N=”Name”;E={$VM.Name}},DiskPath, @{N=”Capacity(MB)”;E={[math]::Round($_.Capacity/ 1MB
    )}}, @{N=”Free Space(MB)”;E={[math]::Round($_.FreeSpace / 1MB)}}, @{N=”Free Space %”;E={[math]::Round(((100 * ($_.FreeSpace))/ ($_.Capacity)),0)}}) |
    Format-Table} | <<<< Export-Csv c:\disk
    + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : EmptyPipeElement

Leave a Reply

Your email address will not be published. Required fields are marked *