Share via


Hyper-V 2012 R2 - Rename Virtual Machine

Question

Friday, December 11, 2015 8:14 AM

Hello,

I need your help with a simple question. How can I rename a VM on Hyper-V and the vhdx file?

Do I need to change the XML file as well? 

I found in Powershell a cmdlet called Rename-VM, can I do this from here?

Thank you very much for your help.

HV

All replies (5)

Friday, December 11, 2015 8:24 AM âś…Answered | 2 votes

Hello,

Yes you can do it with this command. To rename the VHD, you need to shutdown the VM and to specify the new VHD name in the Hyper-V VM.

Florent


Friday, December 11, 2015 11:20 AM

You can rename VM in Hyper-V manager or using Rename-VM cmdlet. To rename vhd, you'll need to shut down the VM, rename the vhd-file in file system, then edit VM configuration in Hyper-V manager: remove disk that refers to the "old" path, and add new disk with the new path/name.

Gleb.


Friday, December 11, 2015 3:24 PM

First need to shut down the VM and then you can rename the VHDX file. Then use Hyper-V Manager or Cluster manager to attach the VHDX file to the VM.

Then you can switch on the VM.

Hemal


Friday, December 11, 2015 7:50 PM | 1 vote

You can do it via Hyper-V Manager UI or via Powershell.

Use Rename-VM command. You can rename a VM while it's running.

To rename vhdx with OS:

1) Shutdown the VM

2) Disconnect VHDX file

3) Rename the VHDX file

4) Attach VHDX file again

5) Start the VM.


Saturday, December 12, 2015 1:35 PM

Hi HV,

Agree with the others .

As you mentioned , it is hyper-v 2012R2 server , it is a core server , right ?

If there is a win 8.1 , you can install hyer-v manager then manage the hyper-v server remotely .

If not , you may try the following cmdlets :

1 . Rename-VM -Name OriginalVMname -NewName Newname

2. to rename the VHD file , you may need to locate it first using command "Get-VMHardDiskDrive -VMName xxxx"

From the output of this command you can get more information , such as , controller type , controller number, controller location .

Then you can shutdown that vm then change the vhd name , then , attach that VHD file using "set-VMHardDiskDrive " command :

Best Regards,

Elton Ji

Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected] .