PowerCLI: Virtual Machine Disk (VMDK) info


image

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
            
            if($dev.Backing.ThinProvisioned){
            Write-Host "`t" $dev.DeviceInfo.Label = "Is Thin Provisioned" `
            -ForegroundColor Green}
            else{
            Write-Host "`t" $dev.DeviceInfo.Label = "Is NOT ThinProvisioned" `
            -ForegroundColor Red }
            } 
    }
}

This is the output of the script:

image

Advertisements

2 thoughts on “PowerCLI: Virtual Machine Disk (VMDK) info

  1. Pingback: All In One Information » PowerCLI: Virtual Machine Disk (VMDK) info « ICT-Freak.nl

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s