PowerCLI: Virtual Machine Disk (VMDK) info v2: Analyze data with Excel


In my previous post about this subject I created a script to view the information on the PowerCLI console. With the v2 script you are able to export the data to a CSV file.

$myCol = @()
$vms = get-view -ViewType VirtualMachine  | Where-Object `
{-not $_.config.template} 
foreach($vm in $vms){
    foreach($dev in $vm.config.hardware.Device){
    $MYInfo = "" | Select-Object VMName, DeviceLabel, `
    FileName, DiskMode, ThinProvisioned

       $MYInfo.VMName = $vm.Name

           if($dev.GetType().Name -eq "VirtualDisk"){
                   $MYInfo.DeviceLabel = $dev.DeviceInfo.Label
                $MYInfo.FileName = $dev.Backing.FileName
                $MYInfo.DiskMode = $dev.Backing.DiskMode
                $MYInfo.ThinProvisioned = "True"}
                else{$MYInfo.ThinProvisioned = "False"}

                $myCol += $MYInfo
$myCol | Export-CSV -NoTypeInformation "D:\scripts\vmdkinfo.csv"

When the script is finished, you can import the CSV file into Excel.  After the import, we can analyze the data with just a simple filter. With a few clicks,  you’re able to view al the VM’s without Thin Provisioned disks.


Now we have a list with all the VM’s with Thin Provisioned disks:


So with a small PowerCLI script and the help of Microsoft Excel, you’re able to generate a report with just the information you need. The best part is that it will only cost you couple of minutes of your time 🙂 .


PowerCLI: Virtual Machine Disk (VMDK) info


I was creating a small reporting script about the Virtual Machine disk. The things I wanted to report where the File Name (the location of the VMX file), the disk mode (Independent –> Persistent or nonPersistent) and if the disk is Thin Provisioned or not.  But then I thought why reinventing the wheel if Mr PowerCLI LucD has already created such a script. So I started a search on the VMware communities and found a post of @LucD22 which contains the Thin Provisioned “Check”. So I added the items I wanted to see and came to the following script:

get-view -ViewType VirtualMachine  | Where-Object `
{-not $_.config.template} | % {
Write-Host $_.Name -ForegroundColor Yellow
    foreach($dev in $_.config.hardware.Device){
        if($dev.GetType().Name -eq "VirtualDisk"){
            Write-Host "`t" $dev.DeviceInfo.Label = $dev.Backing.FileName
            Write-Host "`t" $dev.DeviceInfo.Label = $dev.Backing.DiskMode
            Write-Host "`t" $dev.DeviceInfo.Label = "Is Thin Provisioned" `
            -ForegroundColor Green}
            Write-Host "`t" $dev.DeviceInfo.Label = "Is NOT ThinProvisioned" `
            -ForegroundColor Red }

This is the output of the script: