Skip to main content

Move VM

Tags: HyperV VM VHD Compress 

 

 

 

This will move all parts of the VM to a central location.  Through the process it will compress dynamically expanding VHD. 

 

**************** 

 

$vmName = "ACS-05-VSRV01" 

$hostName = "CM-05-SAN01" 

$storagePath = "T:\HyperV\ACS-05-VSRV01" 

  

Move-VMStorage -ComputerName $hostName ` 

               -DestinationStoragePath $storagePath ` 

               -Name $vmName 

******************** 

 

 

 

 

 

 

 

This will move a single VHD file from one location to another. This process will also naturally compress dynamic expanding VHD files (without taking them offline) 

 

****************** 

 

$vmName = "ACS-00-VSRV45" 

$hostName = "CM-05-SAN01" 

 

$vhd= @{"SourceFilePath" = "F:\ACS-00-VSRV45_Wasabi_Local_Extent_2.vhdx";  

        "DestinationFilePath" = "E:\Backup Storage\HyperV Drives\ACS-00-VSRV45_Wasabi_Local_Extent_2.vhdx" 

       } 

 

Move-VMStorage -ComputerName $hostName ` 

               -Name $vmName ` 

               -Vhds $vhd 

******************* 

 

 

 

 

Get VM HDD  disk locations 

********************* 

Get-VM –ComputerName CM-05-SAN01 | 

Get-VMHardDiskDrive | 

Select-Object -Property VMName, Path | 

Sort-Object -Property VMName | 

Out-GridView -Title "Virtual Disks" 

*************************