locked
Reinitialize Virtual Hard Disk RRS feed

  • Question

  • I have a virtual hard disk (VHD) stored on an external USB drive. The external drive does not have a letter assigned; this is to protect its contents from viral attack. In Hyper-V Manager, I added the VHD to a VM by using the DeviceID of the external drive. The virtual hard disk successfully appears in disk management of the VM. However, at some point the VHD becomes detached (perhaps due to a backup running on the Hyper-V host) and does not reattach unless I re-add it in the Hyper-V GUI or restart the VM.

    Is there a Powershell method to reinitialize the detached VHD? I have tried using "Add-VMHardDiskDrive" but it will not accept the DeviceID in the Path argument. A Powershell command which reattaches the VHD seems better than restarting the VM every time the backups run.

    Tuesday, July 14, 2020 4:14 PM

Answers

  • Hi,

    After some research, I'm afraid to say I didn't find information to add VHD hard disk that the powershell command accecpt DeviceID.

    Thanks for your understaning!

    Best Regards,

    Anne


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    • Marked as answer by reid1000 Thursday, July 16, 2020 8:22 PM
    Wednesday, July 15, 2020 4:39 AM
  • Not sure that you should be using the term "reinitialize" for what you are looking to do.  To initialize a disk means that you are destroying all the data on the disk.

    You may want to pose your question to the scripting forum located at https://social.technet.microsoft.com/Forums/en-US/home?forum=ITCG  Though they are not experts in Hyper-V, they are experts in scripting so they may have some ideas.


    tim

    • Marked as answer by reid1000 Thursday, July 16, 2020 8:23 PM
    Thursday, July 16, 2020 12:33 PM

All replies

  • Hi,

    After some research, I'm afraid to say I didn't find information to add VHD hard disk that the powershell command accecpt DeviceID.

    Thanks for your understaning!

    Best Regards,

    Anne


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    • Marked as answer by reid1000 Thursday, July 16, 2020 8:22 PM
    Wednesday, July 15, 2020 4:39 AM
  • Thank you, Anne. And what about a command to simply "reinitialize" the attached disks? Powershell is able to see that the VHD is attached by means of a DeviceID path. Is there a Powershell command which can reinitialize the disk or somehow mimic what occurs during VM restart? When I restart the VM, the VHD reappears.
    Wednesday, July 15, 2020 2:59 PM
  • Not sure that you should be using the term "reinitialize" for what you are looking to do.  To initialize a disk means that you are destroying all the data on the disk.

    You may want to pose your question to the scripting forum located at https://social.technet.microsoft.com/Forums/en-US/home?forum=ITCG  Though they are not experts in Hyper-V, they are experts in scripting so they may have some ideas.


    tim

    • Marked as answer by reid1000 Thursday, July 16, 2020 8:23 PM
    Thursday, July 16, 2020 12:33 PM
  • Thank you, Tim, for your helpful advice. I will use a scheduled task with a powershell script to add and remove the VHD for backups. This will allow me to safely remove the external USB drive on which the VHD is stored so that it can be carried off-site.

    According to Anne, I will need to assign a drive letter to the physical disk's partition so that powershell can do the work.

    Thank you both again for your help.

    Sincerely,
    Reid

    Thursday, July 16, 2020 8:22 PM