Categories
PowerCLI PowerShell Uncategorized vmware

#LFMF VMware datastores are case sensitive!

Working in a Microsoft world with only brief forays into Unix and Apple server technologies, I tend to forget some lessons from those alternatives 🙂

So, today when working on some PowerShell scripts to copy datastore folders around for backup purposes I was a bit stumped by a copy failing as no object was found. The essential components of the script are:

Add-PSSnapin VMware.VimAutomation.Core

Connect-VIServer -Server FQDN of server or vCentre -Protocol https
$datastore = Get-Datastore Test
New-PSDrive -Location $datastore -Name TT -PSProvider VimDatastore -Root \’\\\’
Copy-DatastoreItem \’TT:\\sage\\*\’ \’J:\\esx\\test\\sage\’
start-vm -vm \’Sage\’

The Add-PSSnapin puts the VMware supplied PowerCLI snapins in place to manage ESX/vCentre architecture
Connect-VIServer does what it says on the tin
New-PSDrive creates a PowerShell drive mapping to the datastore in question so that it can be maipulated., and the Copy-DatastoreItem with those parameters copies the entire folder over (you can recurse through folders and so on if you wish, this is a simple copy)

Can you see the mistake, no I couldn\’t either!

The script would fail on the copy-datastoreitem command and jump onto the start-vm. Now I know there should be error handling and all that stuff, but this was a quick 1-off to sort something out.

So I browsed teh data store through the vCentre interface, all was there, the target folders were there…

In the end the Unix issue of capitalisation rang a distant echo. The Sage folder on the datastore was precisely that \”Sage\” not \”sage\”.

Quick edit, and all is running.

Phew!

\’scuse the inappropriate word wraps in the code.

By P J Bryant

Ramblings of a freelance IT Consultant working for some nice SME's, large organisations, resellers and the usual friends and family! Bit of

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s