ESXi 5.5 – Automating VMFS UNMAP w/ PowerCLI and PowerShell

With vSphere 6.5 recently released, a nice feature was the automated execution of the UNMAP command against thin provisioned datastores to reclaim space. This requires no user interaction, it’s fully automated for you and can free up significant amounts of space from your datastores.

There’s some good information regarding the v6.5 release  on these blogs;

ESX Virtualization Vladan Seget

VirtualizationIsLife  Anthony Spiteri

But you don’t necessarily have to upgrade to 6.5 to avail yourself of this cool enhancement, it’s possible, with a little effort to get it working in your existing environment, as long as you are running Esxi 5.5 or 6.0x.

DELL/EMC customers can make use of the VSI Client for vSphere Web Client  which includes this functionality, amongst other cool features. Version 7 supports a range of kit including XtremIO and VPLEX, VNX etc.

Admin Guide here 

PowerCLI and run via regular Windows Scheduled Tasks is my preferred method to get this done and comments inline should be clear. Tested Using PowerClI 6.5R1

Script execution in progress;

4-12-2016-10-49-33-pm

The XML to add as a scheduled task is at the bottom of this page; (change values as required)

Running the process adhoc is also very easy. Here run it against a Datastore after already connecting to a server over ssh;

4-12-2016-8-28-51-pm

….or remotely using plink;

4-12-2016-9-36-12-pm

So until you have the go ahead  (for whatever reason) schedule it and enjoy the benefits.

Run the process be executed outside of peak hours. It does tend to tax the disk subsystems.

 

 


<Scheduled Task XML > Set to run from c:\Scripts on the 1st Sunday of each Month @ 10.00 pm

 

Related Post

One thought on “ESXi 5.5 – Automating VMFS UNMAP w/ PowerCLI and PowerShell

  1. thank you for the script, I was looking for something like this.

    I try it but I face issue with Get-PSSnapin -Name VMware.VimAutomation.Core

    I don’t have “VMware.VimAutomation.Core” how I can get it ?

    I’m running the script on my client machine.

Leave a Reply

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