Migrating non-VM data between two ESXi datastores

Sometimes in the course of your work you’ll find that you need to move data between two datastores on your ESXi host or vCenter server. In my case, this occured twice, once when adding shared storage to my home lab and again when migrating some hosts from VC 5.1 to 5.5 at work. VM data is best moved via storage vMotions, but this may still leave a few files on your datastore, such as the ubiquitous ISOs folder. You could download the files from the datastore, save them on your client, and then upload them to the datastore. That’s fairly clunky, especially with the Web Client, but more importantly, it’s slow and tedious. There’s another way.

The answer is to use PowerCLI and a PSDrive. If you are not familiar with PSDrives, check out this article at the Hey, Scripting Guy! Blog for a primer. The most important command to remember is Get-PSDrive, as that will give you all the information you need to do this again in the future without having to reference this article. If you have PowerCLI installed, you will have a shortcut on your desktop for it. This will launch a window that looks like the command prompt. If you want a little more help as you drive (and you will!), I suggest using PowerShell ISE for tab completion and IntelliType. You can add the PowerCLI snapins with the following commands from the ISE:

Continue reading