linux admins worst nightmare


okay so you have taken over a vmware environment and your ocd is burning out your eyeballs because the old naming convention contained uppercase characters.

for those not aware… When you do anything from the command line with linux it is case aware, so if I typed something like this on an esx(i) host.

I want to capture all network traffic going through an esx host and filter by a certain hostname.
So I run on a host using putty.

tcpdump-uw | grep

But I get no results because some muppet has put the hostname as HostNamE so I need to type

tcpdump -uw | grep

grrr – does not sound frustrating but trust me when you are looking after a large environment and need to launch the viclient or powercli to get the correct mix of upper and lowercase it becomes frustrating.

So lets change all to lowercase shall we..

This is the magic bit here…

get-?? | ForEach { $_ | set-?? -Name ($_.Name).tolower()}

So as a few examples.


get-vm | ForEach { $_ | set-vm -Name ($_.Name).tolower()}

note – when you change the port groups from upper to lower the vm’s will automatically adjust (tested on vsphere 5.5)

get-vdportgroup | ForEach { $_ | set-vdportgroup -Name ($_.Name).tolower()}

To hit just one port group for testing.

get-vdportgroup dv-wHaCkdiDdy | ForEach { $_ | set-vdportgroup -Name ($_.Name).tolower()}


Get-Folder | ForEach { $_ | set-Folder -Name ($_.Name).tolower()}

That should give you enough to continue with.

Apologies to the person I stole this initial bit of magic from that got me started..

Get-VM | Foreach { $_ | Set-VM -Name ($_.Name).tolower()}