linux admins worst nightmare

EVERYTHING IN UPPERCASE… grrrr..

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 hostname.whackddidy.com.au

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

tcpdump -uw | grep HostNamE.whackdiddy.com.au

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.

vm’s

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

dv-portgroups
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()}

folders.

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()}