Migrating VM Storage

Migrating VM Storage

Q: How can I migrate all storage for VMs using a specific disk?

A: All storage for virtual machines (VMs) on a specific disk can be moved with a single line of Windows PowerShell. The command below moves the storage of all VMs using a specific disk to the new location in a subfolder named for the VM.

In the example, I use the -WhatIf switch so no migration will actually be performed. Use this first to confirm the actions that will be taken, then run the command without -WhatIf to actually perform the migration.

In the example below all virtual machines on the E:\ drive are moved to D:\virtuals. For example, a VM named savdalcm01 would be moved to a folder D:\virtuals\savdalvm01.

Get-VM | Get-VMHardDiskDrive | where {$_.Path.StartsWith("E:\")} | ForEach-Object {Move-VMStorage -VMName $_.VMName -DestinationStoragePath ("D:\virtuals\"+$_.VMName) -WhatIf}

 

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish