Select Page

Had a slightly time consuming problem today where it was necessary to alter a bunch of volume assignments that had been made within a stack of virtual machine guests I have been given.

Under normal circumstances, changing a drive letter (even with the deprecated Windows 2012 interface) is simple, spin up compmgmt.msc and change away! Unfortunately with 12 VMs and 5 volumes to be changed per VM, this would be both lengthy and boring, perfect as a candidate task for a little PowerShell!

The script I knocked up simply takes arguments (old volume and new volume) and then, with some checking on the way, looks up the old name and changes it to the new name.

Checks built into the script:

  • have old and new names been passed to the function?
  • is the new name available?
  • does the old volume exist?

Nice and simple using a snip of WMI (to ensure compatibility with Windows 2008 etc.) plus a quick call into the System namespace.

As always, the script is provided here as-is, no warranty, etc. yada yada yada – test, test, test!

You can find the script here.

more to follow…