VMware Cloud Community
JayScheponik
Contributor
Contributor

PowerCLI Script for VM Disk over 250GB

So you may be mid-planning for your upgrade to 5.x but still adding to your current environment. As you add datastores the question of block size comes up. Here is a script to list any VMs with a disk greater than 250GB (yes, 256 is the magic number but lets be honest...who really makes a 256GB disk). If you don't have any VMs greater than 250, stick with the 1MB so conversion to VMFS5 is just a little easier.

$data = @()

$vc = "YOUR VC"

Connect-VIServer $vc

$vms = Get-VM

foreach($vm in $vms)

{

     $disks = $vm | Get-HardDisk | where {$_.CapacityKB -gt 262144000}

     if($disks -ne $null)

     {

          foreach($d in $disks)

          {

           $myItem = "" | Select VM , Disk , Size

           $myItem.VM = $vm.Name

           $myItem.Disk = $d.ExtensionData.DeviceInfo.Label

           $myItem.Size = [math]::round(($d.CapacityKB / 1048576),2)

           $data += $myItem

          }

     }

}

Disconnect-VIServer -Server * -Confirm:$false

$data

0 Kudos
1 Reply
vmroyale
Immortal
Immortal

Note: Discussion successfully moved from VMware vCenter™ to VMware vSphere™ PowerCLI

Brian Atkinson | vExpert | VMTN Moderator | Author of "VCP5-DCV VMware Certified Professional-Data Center Virtualization on vSphere 5.5 Study Guide: VCP-550" | @vmroyale | http://vmroyale.com
0 Kudos