none
Script Returns "No ProtectionGroup found" When existing a PG on DPM 2012. RRS feed

  • Question

  • Hello,

    I'm new to PowerShell and I got the script below (credits: EverydayNerd.com) with the intention to modify the protection group to manually initiate a recovery point.
    The problem is that when I submit the name of the protection group, that exists in DPM, it returns the following error:

    "No ProtectionGroup found
    At C:\File Server\RecoveryPoint.ps1:67 char:14
    +      Throw <<<<    "No ProtectionGroup found"
           + CategoryInfo           : OperationStopped: <No ProtectionGroup found:String> [], RuntimeException
           + FullyQualifiedErrorId : No ProtectionGroup found"

    But the protection group actually exists in DPM.

    Follows the script:

    ----------------------------------------------------------------------------------------------------------------------------------------------------------

    param([string] $dpmname, [string] $pgname, [string] $backupoption)
    # Clear the screen
    cls
    #Get name of Localhost
    $CompStat = Get-WmiObject win32_computersystem
    $Localhst = $CompStat.Name

    # Notify that connected to Localhost
    write-host ""
    write-host "Script: Create-RecoveryPoint" -foregroundcolor Blue -backgroundcolor white
    write-host ""
    write-host ""
    Write-host "Connected to Localhost: $Localhst" -foregroundcolor Blue -backgroundcolor white
    write-host ""
    write-host ""

    # Set DPM Servername
    $dpmname = read-host "DPM Server Name (Enter for $Localhst):"
        if ($dpmname -eq "")
         {
       $dpmname = $Localhst
       write-host "Using Localhost $dpmname " -foregroundcolor green
       write-host ""
       write-host ""
      }

    # List Protection Groups on DPM server
    $pglist = get-protectiongroup -DPMServerName $dpmname
    write-host "Protection Groups on $dpmname :" -foregroundcolor green
    write-output $pglist
    write-host ""
    write-host ""

    #Enter name of Protection Group you wish to create Recovery Point
    $pgname =  read-host "Enter Protection Group Name:"
    write-host ""
    write-host ""

    #List choices for JobChoice1 Variable
    write-host "1: Express Full"
    write-host "2: Incremental"
    write-host ""

    $JobChoice1 = read-host "Enter Backup type - 1 or 2 [Default is 1: Express Full]:"

    switch ($JobChoice1)
       {
        1 { $backupoption = 'ExpressFull' }
        2 { $backupoption = 'Incremental' }
    default { $backupoption = 'ExpressFull' }
            }
    write-host ""
    Write-host "You selected $backupoption" -foregroundcolor Blue -backgroundcolor white
    write-host ""

    trap{"Error in execution... $_";break}

        if($clipg -eq $abc)
        {
            write-host ""
            Throw "No ProtectionGroup found"
            write-host ""
        }
        else
        {
        write-host ""
        write-host "Getting DataSource from Protection Group $pgname..." -foregroundcolor green
        write-host ""

    # Create variable of each Datasource from Protection Group
        $backupds = @(Get-Datasource $clipg)
       
    # Run the Job for each DataSource in Protection Group     
        foreach ($ds in $backupds)
        { 
            write-host ""
            write-host "Creating Recovery point for $ds..." -foregroundcolor Blue -backgroundcolor white      
            write-host ""

        $job = New-RecoveryPoint -Datasource $ds -Disk -BackupType $backupoption
            $jobtype = $job.jobtype
            Write-host "$jobtype Job has been triggerred..." -foregroundcolor green
        }
        }

    ------------------------------------------------------------------------------------------------------------------------------------------------------

    My environment is:

    Windows Server 2012, DPM 2012 SP1, all with all updates.

    Can anyone help me?

    Thanks,

    Jorge Barata


    Jorge Barata - Microsoft MVP | http://www.jorgebarata.eti.br | Twitter: @jbarata

    Tuesday, April 30, 2013 12:39 PM

Answers

  • This should work (testing on 2012 SP1 - no update rollups):

    Only tested express full backup option

    param([string] $dpmname, [string] $pgname, [string] $backupoption) 
    # Clear the screen
    cls
    #Get name of Localhost
    $CompStat = Get-WmiObject win32_computersystem
    $Localhst = $CompStat.Name
    # Notify that connected to Localhost
    write-host ""
    write-host "Script: Create-RecoveryPoint" -foregroundcolor Blue -backgroundcolor white
    write-host ""
    write-host ""
    Write-host "Connected to Localhost: $Localhst" -foregroundcolor Blue -backgroundcolor white
    write-host ""
    write-host ""
    # Set DPM Servername
    $dpmname = read-host "DPM Server Name (Enter for $Localhst):"
        if ($dpmname -eq "")
         {
       $dpmname = $Localhst
       write-host "Using Localhost $dpmname " -foregroundcolor green
       write-host ""
       write-host ""
      }
    # List Protection Groups on DPM server
    $pglist = get-protectiongroup -DPMServerName $dpmname
    write-host "Protection Groups on $dpmname :" -foregroundcolor green
    write-output $pglist
    write-host ""
    write-host ""
    #Enter name of Protection Group you wish to create Recovery Point
    $pgname =  read-host "Enter Protection Group Name:"
    $clipg = get-protectiongroup -DPMServerName $dpmname | where-object {$_.name -eq $pgname}
    write-host ""
    write-host ""
    #List choices for JobChoice1 Variable
    write-host "1: Express Full"
    write-host "2: Incremental"
    write-host ""
    $JobChoice1 = read-host "Enter Backup type - 1 or 2 [Default is 1: Express Full]:"
    switch ($JobChoice1)
       {
        1 { $backupoption = 'ExpressFull' }
        2 { $backupoption = 'Incremental' }
    default { $backupoption = 'ExpressFull' }
            }
    write-host ""
    Write-host "You selected $backupoption" -foregroundcolor Blue -backgroundcolor white
    write-host ""
    trap{"Error in execution... $_";break}
        if($clipg -eq $abc)
        {
            write-host ""
            Throw "No ProtectionGroup found"
            write-host ""
        }
        else
        {
        write-host ""
        write-host "Getting DataSource from Protection Group $pgname..." -foregroundcolor green
        write-host ""
    # Create variable of each Datasource from Protection Group 
        $backupds = @(Get-DPMDatasource $clipg)
        
    # Run the Job for each DataSource in Protection Group      
        foreach ($ds in $backupds)
        {  
            write-host ""
            write-host "Creating Recovery point for $ds..." -foregroundcolor Blue -backgroundcolor white       
            write-host ""
        $job = New-RecoveryPoint -Datasource $ds -Disk -BackupType $backupoption
            $jobtype = $job.jobtype
            Write-host "$jobtype Job has been triggerred..." -foregroundcolor green
        }
        }

    Edit: added for clarity

    The above changes just return the Protection group as an object (not a string) and make use of the Get-DPMDataSource cmdlet (as opposed to your Get-DataSource)

    Also, in your script you're trying to retrieve the datasource from your '$clipg' vaiable - this has not been defined and is null up tio the point of use - you're setting your PG name as $pgname and only using that in the explanatory text.

    Cheers

    • Edited by IT Badger Wednesday, May 1, 2013 12:46 PM Additional gumpf!
    • Proposed as answer by IT Badger Wednesday, May 1, 2013 12:57 PM
    • Marked as answer by Jorge Barata [JB] Thursday, May 2, 2013 11:51 AM
    Wednesday, May 1, 2013 12:39 PM

All replies

  • This should work (testing on 2012 SP1 - no update rollups):

    Only tested express full backup option

    param([string] $dpmname, [string] $pgname, [string] $backupoption) 
    # Clear the screen
    cls
    #Get name of Localhost
    $CompStat = Get-WmiObject win32_computersystem
    $Localhst = $CompStat.Name
    # Notify that connected to Localhost
    write-host ""
    write-host "Script: Create-RecoveryPoint" -foregroundcolor Blue -backgroundcolor white
    write-host ""
    write-host ""
    Write-host "Connected to Localhost: $Localhst" -foregroundcolor Blue -backgroundcolor white
    write-host ""
    write-host ""
    # Set DPM Servername
    $dpmname = read-host "DPM Server Name (Enter for $Localhst):"
        if ($dpmname -eq "")
         {
       $dpmname = $Localhst
       write-host "Using Localhost $dpmname " -foregroundcolor green
       write-host ""
       write-host ""
      }
    # List Protection Groups on DPM server
    $pglist = get-protectiongroup -DPMServerName $dpmname
    write-host "Protection Groups on $dpmname :" -foregroundcolor green
    write-output $pglist
    write-host ""
    write-host ""
    #Enter name of Protection Group you wish to create Recovery Point
    $pgname =  read-host "Enter Protection Group Name:"
    $clipg = get-protectiongroup -DPMServerName $dpmname | where-object {$_.name -eq $pgname}
    write-host ""
    write-host ""
    #List choices for JobChoice1 Variable
    write-host "1: Express Full"
    write-host "2: Incremental"
    write-host ""
    $JobChoice1 = read-host "Enter Backup type - 1 or 2 [Default is 1: Express Full]:"
    switch ($JobChoice1)
       {
        1 { $backupoption = 'ExpressFull' }
        2 { $backupoption = 'Incremental' }
    default { $backupoption = 'ExpressFull' }
            }
    write-host ""
    Write-host "You selected $backupoption" -foregroundcolor Blue -backgroundcolor white
    write-host ""
    trap{"Error in execution... $_";break}
        if($clipg -eq $abc)
        {
            write-host ""
            Throw "No ProtectionGroup found"
            write-host ""
        }
        else
        {
        write-host ""
        write-host "Getting DataSource from Protection Group $pgname..." -foregroundcolor green
        write-host ""
    # Create variable of each Datasource from Protection Group 
        $backupds = @(Get-DPMDatasource $clipg)
        
    # Run the Job for each DataSource in Protection Group      
        foreach ($ds in $backupds)
        {  
            write-host ""
            write-host "Creating Recovery point for $ds..." -foregroundcolor Blue -backgroundcolor white       
            write-host ""
        $job = New-RecoveryPoint -Datasource $ds -Disk -BackupType $backupoption
            $jobtype = $job.jobtype
            Write-host "$jobtype Job has been triggerred..." -foregroundcolor green
        }
        }

    Edit: added for clarity

    The above changes just return the Protection group as an object (not a string) and make use of the Get-DPMDataSource cmdlet (as opposed to your Get-DataSource)

    Also, in your script you're trying to retrieve the datasource from your '$clipg' vaiable - this has not been defined and is null up tio the point of use - you're setting your PG name as $pgname and only using that in the explanatory text.

    Cheers

    • Edited by IT Badger Wednesday, May 1, 2013 12:46 PM Additional gumpf!
    • Proposed as answer by IT Badger Wednesday, May 1, 2013 12:57 PM
    • Marked as answer by Jorge Barata [JB] Thursday, May 2, 2013 11:51 AM
    Wednesday, May 1, 2013 12:39 PM
  • IT Badger,

    Thank you very much!

    Works fine!! Awesome!! :D

    Best regards,


    Jorge Barata - Microsoft MVP | http://www.jorgebarata.eti.br | Twitter: @jbarata

    Thursday, May 2, 2013 11:53 AM
  • Works great. Thanks a lot.
    Friday, October 25, 2013 12:42 PM
  • It seems it doesn't work for me. I am on a DPM 2012 R2 with latest updates.

    I get this:

    Script: Create-RecoveryPoint


    Connected to Localhost: SERVERNAME


    DPM Server Name (Enter for SERVERNAME)::
    Using Localhost SERVERNAME


    Protection Groups on SERVERNAME :

    Name                                                        ProtectionMethod
    ----                                                        ----------------
    DFS_RO                                                      Short-term using disk | Long-term using tape
    RODAG01                                                     Short-term using disk
    BackupLinux                                                 Long-term using tape
    Qlik                                                        Short-term using disk


    Enter Protection Group Name:: BackupLinux


    1: Express Full
    2: Incremental

    Enter Backup type - 1 or 2 [Default is 1: Express Full]:: 1

    You selected ExpressFull


    Getting DataSource from Protection Group BackupLinux...


    Creating Recovery point for M:\ on computer SERVERNAME.DOMAIN.local...

    Error in execution... Parameter set cannot be resolved using the specified named parameters.
    New-DPMRecoveryPoint : Parameter set cannot be resolved using the specified named parameters.
    At C:\_Scripts\BatchScripts\TriggerTapeBackup.ps1:70 char:12
    +     $job = New-RecoveryPoint -Datasource $ds -Tape -BackupType $backupoption -Pr ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidArgument: (:) [New-DPMRecoveryPoint], ParentContainsErrorRecordException
        + FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.Internal.EnterpriseStorage.Dls.UI.Cmdlet.ProtectionCmdLe
       ts.CreateRecoveryPoint

    PS C:\_Scripts\BatchScripts>

    No matter how I try to pass (I tried manually without the script) the "Datasource" seems to be the problem. I just don't get it why it doesn't work.

    Any ideeas?

    Thanks.

    Tuesday, December 22, 2015 11:21 AM