none
Add clients to Protection Group with Powershell RRS feed

  • Question

  • I am trying to add a domain client computer to a protection group with powershell. If I go the manual way (Add clients to protection group) I can see all of my domain computers in the list "Select Group Members" and them add them.

    How do I do this with powershell? I've seen a couple of example scripts but none of them answers this question.

    The command, Get-Datasource seem to only display computers already protected.

     

    Thanks

    Tuesday, August 30, 2011 8:36 AM

Answers

  • Hi,

    try the following :

      $PGNAME = "<Your PG Name>"
      $DPMServer = "<Your DPM Server Name>"
      $Client = "<The Client Computer Name>"
      
      $pg = Get-ProtectionGroup -DPMServerName $DPMServer | Where-Object {$_.FriendlyName.ToUpper() -eq $PGNAME.ToUpper()}
      $Modpg = Get-ModifiableProtectionGroup -ProtectionGroup $pg
      $ds = Get-DataSource -ComputerNames $Client -DPMServerName $DPMServer
      Add-ChildDataSource -ProtectionGroup $Modpg -ChildDataSource $ds
      Set-ProtectionGroup -ProtectionGroup $Modpg
    


    Tuesday, August 30, 2011 12:35 PM

All replies

  • Hi,

    try the following :

      $PGNAME = "<Your PG Name>"
      $DPMServer = "<Your DPM Server Name>"
      $Client = "<The Client Computer Name>"
      
      $pg = Get-ProtectionGroup -DPMServerName $DPMServer | Where-Object {$_.FriendlyName.ToUpper() -eq $PGNAME.ToUpper()}
      $Modpg = Get-ModifiableProtectionGroup -ProtectionGroup $pg
      $ds = Get-DataSource -ComputerNames $Client -DPMServerName $DPMServer
      Add-ChildDataSource -ProtectionGroup $Modpg -ChildDataSource $ds
      Set-ProtectionGroup -ProtectionGroup $Modpg
    


    Tuesday, August 30, 2011 12:35 PM
  • Was that any help to you?
    Friday, September 2, 2011 4:27 PM
  • Wow, sorry for the superlate respond.

     

    I will try this ASAP and get back to you.

     

    Thanks!!!!

    Thursday, September 22, 2011 10:39 AM
  • Worked like a charm!!!!! Thank you so much!
    Thursday, September 22, 2011 3:31 PM
  • hey.. jeremy...

    can you tell me how to add a server machine to the protection group??????????????? im unable to a add a server machine to the protection group using the above code

    Friday, October 12, 2012 2:07 PM
  • Love this.  Works like a champ AND it was highly instructive (to me at least) on dpm2010 powershell scripting.  Not a bunch of gobbledygook and undeed constructs.
    Monday, October 22, 2012 7:14 PM
  • Hi,

    try the following :

      $PGNAME = "<Your PG Name>"
      $DPMServer = "<Your DPM Server Name>"
      $Client = "<The Client Computer Name>"
      
      $pg = Get-ProtectionGroup -DPMServerName $DPMServer | Where-Object {$_.FriendlyName.ToUpper() -eq $PGNAME.ToUpper()}
      $Modpg = Get-ModifiableProtectionGroup -ProtectionGroup $pg
      $ds = Get-DataSource -ComputerNames $Client -DPMServerName $DPMServer
      Add-ChildDataSource -ProtectionGroup $Modpg -ChildDataSource $ds
      Set-ProtectionGroup -ProtectionGroup $Modpg
    


    This code worked great on older version of DPM but gives me an error on our new DPM2016.

    Any idea how we can get it to work again :)?

    Thx,

    Set-ProtectionGroup : Operation failed since the protected data source size had not been calculated for EUVNL-L160602.corp.nuskin.net\User data on EUVNL-L160602.corp.nuskin.net prior to 
    running this operation. (ID: 31000)
    Ensure that Get-DatasourceDiskAllocation and Set-DatasourceDiskAllocation are executed successfully prior to running this operation.
    At C:\PowerShellScripts\EMEAUsers-DPMAddClient.ps1:19 char:3
    +   Set-ProtectionGroup -ProtectionGroup $Modpg
    +   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Set-DPMProtectionGroup], DlsException
        + FullyQualifiedErrorId : CalculateSizePending,Microsoft.Internal.EnterpriseStorage.Dls.UI.Cmdlet.ProtectionCmdLets.CommitProtectionGroup

    Thursday, March 16, 2017 3:59 PM
  • Hi,

    In 2016 you have to call Set-DataSourceDiskAllocation every time you add a new client ds.

    $pcName = "PCNAME"
    $pgName = "Protection Group"
    
    $mpg = Get-ProtectionGroup | where { $_.Name -like $pgName } | Get-ModifiableProtectionGroup
    
    $clientDS = Get-Datasource -ComputerName $pcName 
    
    Add-ChildDatasource -ProtectionGroup $mpg -ChildDatasource $clientDS
    
    Set-DatasourceDiskAllocation -ProtectionGroup $mpg -ExpectedDataSizePerClientInMB ($mpg.ClientPGDetailsField.ExpectedDataSizePerClient/(1024*1024))
    
    Set-ProtectionGroup -ProtectionGroup $mpg 


    http://www.purgar.net

    Wednesday, April 5, 2017 9:11 PM
  • Hi ,

    I tried your solution in 2016 and I get this error

    Set-DatasourceDiskAllocation : The parameter ExpectedDataSizePerClientInMB cannot be used while configuring protection of the selected data source. (ID: 7006)

    Any help is greatly appreciated

    Here is the code

     $PGName = "HVGP01"
     $dpmservername = "DPMSRV01.domain.com"
     $PGList = @(Get-ProtectionGroup $dpmservername)
    $PG = $PGlist | where { $_.FriendlyName -ieq $PGName}
     
     
     $MPG = Get-dpmModifiableProtectionGroup $PG
    $ps01 = Get-DPMProductionServer -DPMServerName $dpmservername | ? Servername -eq "TEST01"
    $ds01 = Get-DPMDatasource -ProductionServer $ps01 | ? Name -eq 'RCT\TEST01'

    Add-DPMChildDatasource -ProtectionGroup $MPG -ChildDatasource $ds01

    #$DataSourceVolume = Get-DPMDatasource -ProductionServer $ps01 | ? Name -eq 'RCT\TEST01'
    Get-DatasourceDiskAllocation -Datasource $ds01
    Set-DPMDatasourceDiskAllocation -ProtectionGroup $MPG -Datasource $ds01 -PassThru
    Set-ReplicaCreationMethod -ProtectionGroup $MPG -Now
    Set-protectiongroup $MPG

    I'm getting the following error

    PS C:\Windows\system32> Add-DPMChildDatasource -ProtectionGroup $MPG -ChildDatasource $ds01
    Add-DPMChildDatasource : RCT\TEST01 cannot be added to protection because it is already a member of a protection group (ID: 157)
    At line:1 char:1
    + Add-DPMChildDatasource -ProtectionGroup $MPG -ChildDatasource $ds01
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Add-DPMChildDatasource], DlsException
        + FullyQualifiedErrorId : ProtectedGroupOverlap,Microsoft.Internal.EnterpriseStorage.Dls.UI.Cmdlet.ProtectionCmdLets.AddProtectableObject

    PS C:\Windows\system32> Get-DatasourceDiskAllocation -Datasource $ds01

    Computer Name        ObjectType       
    -------- ----        ----------       
    TEST01  RCT\TEST01 Microsoft Hyper-V



    PS C:\Windows\system32> Set-DPMDatasourceDiskAllocation -ProtectionGroup $MPG -Datasource $ds01 -PassThru
    Set-DPMDatasourceDiskAllocation : The item RCT\TEST01 does not exist in protection group Hyper-V Protection Group. (ID: 31019)
    At line:1 char:1
    + Set-DPMDatasourceDiskAllocation -ProtectionGroup $MPG -Datasource $ds ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Set-DPMDatasourceDiskAllocation], DlsException
        + FullyQualifiedErrorId : PODoesNotExistInPG,Microsoft.Internal.EnterpriseStorage.Dls.UI.Cmdlet.ProtectionCmdLets.SetDiskAllocation



    • Edited by master1982 Wednesday, April 3, 2019 4:28 PM
    Wednesday, April 3, 2019 3:06 PM
  •  I found the problem and fixed it and all seems working.The problem  lies with two

    1. I was using SCVMM script to create a VM, which places the VHDX disk and VM config file in random place as opposed to the specified location

    2. In DPM script, we need to query the cluster for list of VMs  prior to getting Production server and Data source.




    • Proposed as answer by master1982 Monday, April 8, 2019 12:57 PM
    • Edited by master1982 Monday, April 8, 2019 12:59 PM
    Monday, April 8, 2019 12:56 PM