Tuesday, January 24, 2012

Uploading to WebDAV using powershell

Its not commonly used, but I find WebDAV to be one of the more useful file transfer methods on the internet. It is secure (as secure as SSL can be), it can be accessed via web browsers, and drives can be mapped to it.
The only problem is that (under Windows) it is normally access by a user profile, and not the entire system. This can be a problem if you are trying to automate copy jobs or backups to the WebDAV share.

I found a great post at http://www.vnext.be/2010/05/20/powershell-upload-file-to-webdav-server/, that shows how to use PowerShell to copy to WebDAV. Its not an entirely elegant solution, but it can be scripted and user/password credentials can be stored to allow automated tasks to access it.



Thursday, January 19, 2012

Importing VMware flat.vmdk file

Someone sent me a file today and told me to import it into VMware. I looked at it briefly and noticed that it was a single file named server-flat.vmdk.
Normally VMware uses multiple files, a VMX, a VMDK, and a -FLAT.VMDK, but here I was just given the one. The FLAT file contains all the disk, so this was the most important file. But the other files are descriptors that tell VMware how to use the disk - What OS, what controller, disk geometry, etc...

A little googling and I found my solution at http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1002511. The basic steps are below:

  1. Import the VMDK file to a datastore
  2. Create a VM with the OS and RAM characteristics needed - dont create/attach a disk
  3. Putty to an ESX host
  4. Find the datastore the VMDK was imported into and do an LS -LA to view the file size in bytes
  5. In the VM folder, run  vmkfstools -c 4294967296 -a lsilogic -d thin temp.vmdk
    1. The size, name, and controller type will vary
  6. Delete the new -FLAT.VMDK file
  7. Move the original -FLAT.VMDK file into this folder
  8. Add the newly created VMDK to the VM

Tuesday, January 17, 2012

SVmotion individual harddisks via PowerShell

I ran into an issue today where I wanted to SVmotion several large virtual disks to different datastores. I didnt want to use the VC because I would either have to 1) Kick off all migrations at the same time, or 2) wait and watch for each disk to finish before launching the next migration.

I knew I could move the whole VM using Powershell, and then I came across this link: http://mrpointy.wordpress.com/2011/07/05/storage-vmotion-only-one-harddisk-via-powershell/. This shows how to identify a single disk and move it to a separate datastore. Queue up these commands in notepad and then past them into PS and they will automatically launch one after the other. Below is an example command


get-harddisk -vm cvmedia51 | where {$_.Name -eq "Hard disk 3"} | % {set-harddisk -harddisk $_ -Datastore TKPD_T3_L070001_02 -Confirm:$false}