action.
3 . Click Next on the Before You Begin page of the wizard.
4 . Since we are moving only the storage, select the Move The Virtual Machine’s
Storage option.
5 . You can now choose to move all of the virtual machine’s data to a single location,
which is the default, or you can select to move the virtual machine’s data to a
different location or move only the virtual hard disks for the virtual machine but
none of its other data. Make your selection and click Next.
6 . If you selected the default to move everything to a single location, you will be
prompted for the new storage location. Just click Next. If you selected either of the
other two options, you will have a separate page to select the target location for
each element of the virtual machine’s data, so set the location for each item, and
click Next.
7 . Review your options, and click Finish to initiate the storage migration.
To perform the storage migration from PowerShell, use the Move-VMStorage cmdlet. If
you’re moving everything to a single location, it’s easy; you just pass the virtual
machine name and the new target location with the DestinationStoragePath
parameter (note that a subfolder with the VM name is not created automatically, so if
you want the VM in its own subfolder, you need to specify that as part of the target
path). Here’s an example:
Move-VMStorage -DestinationStoragePath <target path> ‐VMName <vmname>
If, however, you want to move the parts to different locations, it’s more complicated.
Instead of DestinationStoragePath, the SmartPagingFilePath, SnapshotFilePath, and
VirtualMachinePath parameters are used to pass the location for the smart paging file,
snapshots, and virtual machine configuration, respectively, but this still leaves the
virtual hard disks. For the VHDs, the Vhds parameter is used. You could have more
than one VHD for a single virtual machine (in fact you could have hundreds), and
PowerShell does not really like an arbitrary number of parameters. Therefore, to pass
the virtual hard disk’s new location, you have to create a hash value for
SourceFilePath and DestinationFilePath for each virtual hard disk and then place
those into an array that is passed to the –Vhds parameter. Pleasant!
In the following example, a virtual machine is being moved with three hard disks and
its smart paging file, configuration, and snapshots. You don’t have to move all of the
elements of a virtual machine; you need to specify only the pieces you wish to move.
Other elements not specified would just stay in their current location. Note that in the
following command, curly brackets {} are used for the hash values (value pairs), while
parentheses()are used for the array.
Move-VMStorage -VMName
path> `
-SnapshotFilePath