Skip navigation
Migrating Virtual Machine Storage

Migrating Virtual Machine Storage

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

A: The command below moves the storage of all virtual machines (VMs) using the 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 VMs 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