Cleaning your vCloud Director Thumbnails (current.png)

June 15, 2013

Table of Contents

Thumbnail images are used by vCloud Director to give you a preview of the screen without opening up to the remote console, the dark side is when you migrate/svMotion a machine managed by vCloud Director, it leaves a folder along with the thumbnail, this thumbnails are created and stored by vCloud Director as current.png on the datastore in the VM’s folder.so if you are in your datastores and VMsa look or sometimes get sloopy. This PowerCLI script helps solve this, it goes through a particular datastore, and deletes all abandoned current.png files and the VM folder, this process keeps your datastores neat.

$datastore = “MyDatastore”

$viserver = “MyVIServer”

# add PowerCLI snapin

Add-PSSnapin vmware.vimautomation.core -ErrorAction:SilentlyContinue

# Connect to VI Server

Connect-VIServer $viserver

# Get the datastore we want to clean up

$dsObject = Get-Datastore $datastore

# Create a new PSDrive to that datastore

New-PSDrive -Location $dsObject -name ds -PSProvider VimDatastore -root ”

# Set location to that drive

Set-Location ds:

# From here we are going to parse through

# folders first looking for vmx files,

# if there are no vmx files,

# test for current.png and then remove the thumbnail and folder.

$dsfolders = Get-ChildItem

foreach ($dsfolder in $dsfolders)

{

    if (!(test-path “$dsfolder*.vmx”))

    {

        if (test-path “$dsfoldercurrent.png”)

        {

            remove-item “$dsfoldercurrent.png”

            if ((get-childitem .$dsfolder* | measure-object).count -lt 1)

            {

                remove-item $dsfolder

            }

        }

    }

}

Home

Share on
Facebook
Twitter
LinkedIn
Pinterest
More posts

Dedicated Servers Quick Guide

What is a Dedicated Servers? Why bother using a dedicated server over a VPS or Shared Hosting?A dedicated server is a server 100% dedicated to your website/project or business needs.

Managing Amazon EC2 VMs from the vSphere client

Automation and mulitplatformsupport is gaining more and more popularity. We already a multihypervisor management tool from VMware for Hyper-V and VMware. From vCloud Automation Center you can create workloads in

dvPortgroup Inheritance

Someone may claim the default settings for portgroup inheritance in the dvSwitches, they may be missing in the vSphere client but they still exist and can be set in the

Get 90% Discount

First 3 People gets the Bonus!
Don't Miss Out Our Big Sale

Get 0-90% On All
247Rack Services

247Rack

The Sale Is Until The End Of March