none
Hyper-V replication remove disks RRS feed

  • Question

  • Hyper-V 2019, Server 2019

    VM has four VHDXs. Need to remove two from replication.

    Compiled statement:

    Set-VMreplication "Server" -ReplicatedDisks (Get-VMHardDiskDrive "Server" -ControllerType SCSI -ControllerNumber 0 -ControllerLocation 2). 

    This will remove Disks from ControllerLocation 0,1,3 But I need to remove from 3 too.

    How would I construct it?

    Friday, July 5, 2019 10:38 PM

Answers

  • Hi,

    Thanks for your question.

    As researched, I relize that Set-VMReplication -ReplicatedDisks specifies all virtual hard disks to include for replication. This parameter can include all the VHDs attached to the virtual mahine or a subset. If excluding a critical disk from this list could prevent the replica virtual machine from starting properly.

    Therefore, I suggest we can use the parameter -ReplicatedDiskPaths for specifying the VHDs attached to the VM , the following is an example,

    PS C:\> $VHDS = @("C:\VHDS\vhd1", "C:\VHDS\vhd2")
    
    PS C:\> Set-VMReplication -VMName "VM01" -ReplicatedDiskPaths $VHDS


    The first command assigns the paths of the virtual hard disks vhd1 and vhd2 to the $VHDS variable.

    The second command specifies the two disks in $VHDS to be a part of the included disk set for replication of virtual machine VM01.

    Then we can use “get-vmreplication | format list*” to show detailed information of the replication.

    Reference:

    https://docs.microsoft.com/en-us/powershell/module/hyper-v/set-vmreplication?view=win10-ps

    Hope above information can help you.

    Highly appreciate your effort and time. If you have any question or concern, please feel free to let me know.

    Best regards,

    Michael


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

    • Marked as answer by Ilya35 Tuesday, July 9, 2019 5:53 PM
    Monday, July 8, 2019 7:33 AM
    Moderator
  • Hi Michael,

    Your response gave me a hint to use comma between parantasis = it worked.

    Command that I used:

    Set-VMreplication "VMname" -ReplicatedDisks (Get-VMHardDiskDrive "VMname" -ControllerType SCSI -ControllerNumber 0 -ControllerLocation 0), (Get-VMHardDiskDrive "VMname" -ControllerType SCSI -ControllerNumber 0 -ControllerLocation 2)

    So to replicate all disks - Set-VMreplication "VMname" -ReplicatedDisks (Get-VMHardDiskDrive "VMname")

    To replicate only certain disks - add (Get-VMHardDiskDrive "VMname" -ControllerType SCSI -ControllerNumber 0 -ControllerLocation 0) and repeat same line for each disk, changing the location or type or controller depending on your situation. Put a comma between each parantasy. 

    Sorry if it's not clear.

    • Marked as answer by Ilya35 Tuesday, July 9, 2019 5:52 PM
    Tuesday, July 9, 2019 5:52 PM

All replies

  • Hello Ilya35,

    Please check the following link for more information about Set-VMReplication command and It's parameters.

    https://docs.microsoft.com/en-us/powershell/module/hyper-v/set-vmreplication?view=win10-ps


    Mark it as answer if your question has solved in order to keep forums updated.

    Monday, July 8, 2019 6:46 AM
  • Hi,

    Thanks for your question.

    As researched, I relize that Set-VMReplication -ReplicatedDisks specifies all virtual hard disks to include for replication. This parameter can include all the VHDs attached to the virtual mahine or a subset. If excluding a critical disk from this list could prevent the replica virtual machine from starting properly.

    Therefore, I suggest we can use the parameter -ReplicatedDiskPaths for specifying the VHDs attached to the VM , the following is an example,

    PS C:\> $VHDS = @("C:\VHDS\vhd1", "C:\VHDS\vhd2")
    
    PS C:\> Set-VMReplication -VMName "VM01" -ReplicatedDiskPaths $VHDS


    The first command assigns the paths of the virtual hard disks vhd1 and vhd2 to the $VHDS variable.

    The second command specifies the two disks in $VHDS to be a part of the included disk set for replication of virtual machine VM01.

    Then we can use “get-vmreplication | format list*” to show detailed information of the replication.

    Reference:

    https://docs.microsoft.com/en-us/powershell/module/hyper-v/set-vmreplication?view=win10-ps

    Hope above information can help you.

    Highly appreciate your effort and time. If you have any question or concern, please feel free to let me know.

    Best regards,

    Michael


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

    • Marked as answer by Ilya35 Tuesday, July 9, 2019 5:53 PM
    Monday, July 8, 2019 7:33 AM
    Moderator
  • Hi,

    Just checking in to see if the information provided was helpful. Please let us know if you would like further assistance.

    Best Regards,

    Michael


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

    • Marked as answer by Ilya35 Tuesday, July 9, 2019 5:52 PM
    • Unmarked as answer by Ilya35 Tuesday, July 9, 2019 5:52 PM
    Tuesday, July 9, 2019 1:56 PM
    Moderator
  • Hi Michael,

    Your response gave me a hint to use comma between parantasis = it worked.

    Command that I used:

    Set-VMreplication "VMname" -ReplicatedDisks (Get-VMHardDiskDrive "VMname" -ControllerType SCSI -ControllerNumber 0 -ControllerLocation 0), (Get-VMHardDiskDrive "VMname" -ControllerType SCSI -ControllerNumber 0 -ControllerLocation 2)

    So to replicate all disks - Set-VMreplication "VMname" -ReplicatedDisks (Get-VMHardDiskDrive "VMname")

    To replicate only certain disks - add (Get-VMHardDiskDrive "VMname" -ControllerType SCSI -ControllerNumber 0 -ControllerLocation 0) and repeat same line for each disk, changing the location or type or controller depending on your situation. Put a comma between each parantasy. 

    Sorry if it's not clear.

    • Marked as answer by Ilya35 Tuesday, July 9, 2019 5:52 PM
    Tuesday, July 9, 2019 5:52 PM
  • Hi,

    Oh, your technical is very appreciated! It would be helpful to others who encounters a similar situation. I'm also very glad that the information here is helpful to you.

    Thanks for your sharing and support.

    Have a nice day!

    Best regards,

    Michael


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

    Wednesday, July 10, 2019 2:39 AM
    Moderator