Migrating VM Storage

All storage for virtual machines on a specific disk can be moved by using a single line of Windows PowerShell--here's how to do it.

John Savill

March 9, 2013

1 Min Read
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:virtualssavdalvm01.

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

 

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like