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.
March 9, 2013
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
You May Also Like