Category Archives: How To….

PowerShell Quick Tip- Letter Frequency

With a list of Surnames in a text file I wanted to see how many start with A, how many with B, and so on. This is my PowerShell solution:

(Get-Content .\surnames.txt).Substring(0,1).ToUpper() |
  Sort-Object | Group-Object |Select-Object Name, Count

Example Input (surnames.txt file):


Example Output:

Name Count
---- -----
A      162
B      372
C      365
D      193
E      187
F      198
G      154
H      321


Mailbox filling up harddisk? Turn Off Cached Exchange Mode

Microsoft OutlookThis came up in conversation at work earlier today- a user has connected to their own mailbox and those of other staff. They now have a whopping 35GB of Outlook files on their workstation. They are having performance issues. Here’s a 30-second highlight of the solution.

Solution: Turn off Cached Exchange Mode in Outlook, reduce the timespan mail is retained locally, or choose not to cache the shared mailboxes.

What is Cached Exchange Mode?
Cached Exchange Mode is used in Outlook to download a local copy of a mailbox on the workstation to allow for offline use. This is the default behaviour when connecting to Exchange and is great for most users, and in particular if you have a poor or intermittent network connection. However when used by people using massive mailboxes it can take up a lot of local hard drive space- you’ll spot some large “.OST” files in the users profile-  and Microsoft advise that performance can become an issue on large (>25GB) mailboxes.

My (default) settings on a workstation look like the screenshot below- Cached Exchange Mode is turned on and set to download the last 12 months of data from all mailboxes I connect to with that account and also the GAL. If I look in C:\Users\username\AppData\Local\Microsoft\Outlook I see that I have an OST file weighing in just under 1.5GB however my mailbox on the Exchange Server (Office365) is 10GB in size. With these settings I can access all the mail I need to, and if I need to look up anything earlier it goes off to the server to retrieve it- this process is barely noticable if I’m connected to the internet.

If I need to reclaim some local disk space, or hit performance issues, I can reduce this local retention time or disable Cached Exchange Mode altogether.

Cached Exchange Mode Settings

ESXi UNMAP not working on Replicated EqualLogic Volume


  • The VMware vSphere ESXi UNMAP command doesn’t release space on some or all volumes on a Dell EqualLogic SAN array running v8 firmware (may apply to other versions too). Using the following command in an SSH session to a 6.0u2 host (again, will apply to other versions):
    esxcli storage vmfs unmap –l MYVOLUMENAME
  • The volumes are VMFS5 (and always have been- they haven’t been upgraded from VMFS3).
  • Replication is enabled for the volumes that won’t rethin.



UNMAP doesn’t work on the EqualLogic when Replication is enabled. It doesn’t return an error to the SSH session, and the temporary rethinning file is still created, but the disk is not thinned.


Disable replication on the volume, re-thin the volume using the UNMAP command, then re-configure replication. Unfortunately this means the entire volume must be re-copied to the replication partner and this may impact bandwidth usage and replication schedules on larger volumes.


Finding Deprecated VMFS Volumes

Following an upgrade to vSphere 6, hosts popped up an error message reporting that some old VMFS volumes were found on the host. Whilst these still worked, it would be prudent to tidy them up and replace them with modern datastores. The message is:

“Deprecated VMFS volume(s) found on the host. Please consider upgrading volume(s) to the latest version”


Whilst this highlights that there is an issue, the GUI message doesn’t indicate which volumes (or how many) are affected. The following quick bit of PowerCLI produces a table of the datastores with a VMFS version of less than 5.

Get-Datastore |
 Where-Object { $_.ExtensionData.Info.VMFS.MajorVersion -lt 5} |
 Select-Object Name, FreeSpaceGB, CapacityGB, @{n='VMFS Version';e={$_.ExtensionData.Info.VMFS.MajorVersion}}

Example Output:

Name           FreeSpaceGB CapacityGB VMFS Version
----           ----------- ---------- ------------
VOL-VM01            574.77    2047.75            3
VOL-VM02           1924.05    2047.75            3

Setting EVC Level on a Cluster with a VCSA and no shared storage


A second host has been added to a one-node vSphere cluster which has no shared storage and EVC cannot be enabled. Details as follows:

  • A vSphere environment consists of an existing cluster containing a single host running ESXi 6. On this host is (amongst other things) the vCenter Server Appliance VM.
  • A second ESXi6 host is added and joined it to the vCenter. This host has older hardware with an older EVC level (rather than the usual situation where the newer box has newer hardware).
  • EVC cannot be enabled on the cluster because the old host does not have the capabilities of the new host. The old host has VMs running which may be using the enhanced capabilities of the higher EVC level, one of these is the vCSA.

    “The host cannot be admitted to the cluster’s current Enhanced vMotion Compatibility mode. Powered-on or suspended virtual machines on the host may be using CPU features hidden by that mode.”

    Therefore the EVC level on the existing cluster cannot be lowered by powering off all the VMs because it cannot be changed without using vCenter.

  • The vCSA cannot be vMotioned to the old host because this requires EVC to be enabled.

    “The virtual machine requires hardware features that are unsupported or disabled on the target host”

  • There is no Shared Storage. VMs are stored on local datastores. The Knowledgebase article “How to enable EVC in vCenter Server (1013111)” has a solution but this doesn’t (as far as I can tell) work without shared storage. Without storage visible from both hosts the VM cannot be disabled in one host and brought back up in a second which is in a new cluster.

Possible Solutions

The problem boils down to needing to cold migrate a VM between ESXi hosts without using shared storage or vCenter. The following solutions came to mind.

  1. Create some shared storage (possibly using an NFS share on a laptop temporarily) and follow the procedure shown in KB1013111
  2. Power down the vCSA, use the host web client to move the files from the datastore to a laptop, then back up to the less-able host. Power it on and set EVC on the cluster.
  3. Dump the vCSA and setup a replacement instance on the less-able host. Reconfigure everything. The “Start Again” option.
  4. Use SCP to do a host-host local datastore transfer of the powered down and unregistered vCSA Virtual Machine files

My Chosen Solution

This is what I tried and tested and it worked in my environment, along with step-by-step instructions if anyone else finds themselves in this predicament (usual disclaimer applies).

Option 4:  Use SCP to do a host-host local datastore transfer of the powered down and unregistered vCSA Virtual Machine files.

Rough steps – “First Host” is the existing box with newer hardware, “Second Host” is the box with older hardware being added:

  1. Using vCSA setup a new cluster containing just the second host (the one with older hardware) and turn on EVC appropriately.
  2. Enable Secure Shell access on both hosts
  3. Shutdown all VMs including the vCSA on the first host
  4. Remove vCSA from inventory (Unregister) using web client on first host
  5. SSH into second host
  6. Enable SCP through the firewall with
    esxcli network firewall ruleset set -e true -r sshClient
    -thanks for that snippet
  7. Use SCP to copy VM files from local datastore on first host to local datastore on second host.
    For example- in SSH session on second host, something like this:
    mkdir /vmfs/volumes/datastore1/LABVC1
    scp ‘[email protected]:/vmfs/volumes/Datastore2/LABVC1/*.*’ /vmfs/volumes/datastore1/LABVC1/
  8. Connect to web client on second host and register the copy of the VMX file to inventory
  9. Turn on the vCSA VM. When prompted say “I moved it”
  10. Wait for vCSA to spin up then move the first host into the cluster with the second host.
  11. Tidy up: -Remember to go back and delete the old copy of the VCSA from the datastore on the first host and disable SSH on both hosts if it’s not required. The vCSA can be Storage-vMotioned to rethin disks if they inflated during the SCP operation.