none
Can't get usable output from Get-ProtectionGroup RRS feed

  • Question

  • I am trying to do some DPM PowerShell scripting and I am running into a fundamental problem.  I can't get anything usable out of the Get-ProtectionGroup command.  I am using the following line of code:

    $pg = Get-ProtectionGroup -DPMServerName <servername>

    When I try to use "$pg" in the next line, I get an error:

     

    Get-Datasource : Cannot convert 'System.Object[]' to the type 'Microsoft.Internal.EnterpriseStorage.Dls.UI.ObjectModel.OMCommon.ProtectionGroup' required by parameter 'ProtectionGroup'. Specified method is not supported.

    At C:\Program Files\Microsoft DPM\DPM\bin\FindRecoveryPoints.ps1:6 char:39

    +  $ds = Get-Datasource -ProtectionGroup  <<<< $pg

    Get-RecoveryPoint : Cannot validate argument because it is null.

    At C:\Program Files\Microsoft DPM\DPM\bin\FindRecoveryPoints.ps1:7 char:31

    +  Get-RecoveryPoint -Datasource  <<<< $ds

     

    When I print $pg to the screen to see what is wrong, I get this (I have 7 protection groups):

    Microsoft.Internal.EnterpriseStorage.Dls.UI.ObjectModel.OMCommon.ProtectionGroup

    Microsoft.Internal.EnterpriseStorage.Dls.UI.ObjectModel.OMCommon.ProtectionGroup Microsoft.Internal.EnterpriseStorage.Dls.UI.ObjectModel.OMCommon.ProtectionGroup Microsoft.Internal.EnterpriseStorage.Dls.UI.ObjectModel.OMCommon.ProtectionGroup Microsoft.Internal.EnterpriseStorage.Dls.UI.ObjectModel.OMCommon.ProtectionGroup Microsoft.Internal.EnterpriseStorage.Dls.UI.ObjectModel.OMCommon.ProtectionGroup Microsoft.Internal.EnterpriseStorage.Dls.UI.ObjectModel.OMCommon.ProtectionGroup

    How do I get something I can actually use in a script?  

    I am running DPM 2007SP1 (ver 2.0.8824.0)

     

    Ian

    Monday, January 31, 2011 10:35 PM

Answers

  • You can't feed $pg directly as a parameter as you are doing with "Get-Datasource -ProtectionGroup $pg"

    This is because $pg is actually an array of protection groups, and Get-Datasource only wants one. Same thing with $ds ... Get-Datasource retrieves an array of objects, not just one.

    Try something like this if you want to iterate through all protection groups and datasources:

     

    $pgList = Get-ProtectionGroup $env:COMPUTERNAME

    ForEach($pg in $pgList) {

      $dsList = Get-Datasource -ProtectionGroup $pg

      ForEach($ds in $dsList) {

        $line = $ds.PSInfo.Name

        $line += "  " + $ds.Name

        $line += "  " + $ds.State

        Write-Output $line

      }

    }

    • Marked as answer by ielverson Tuesday, February 8, 2011 10:57 PM
    Tuesday, February 1, 2011 1:56 AM

All replies

  • You can't feed $pg directly as a parameter as you are doing with "Get-Datasource -ProtectionGroup $pg"

    This is because $pg is actually an array of protection groups, and Get-Datasource only wants one. Same thing with $ds ... Get-Datasource retrieves an array of objects, not just one.

    Try something like this if you want to iterate through all protection groups and datasources:

     

    $pgList = Get-ProtectionGroup $env:COMPUTERNAME

    ForEach($pg in $pgList) {

      $dsList = Get-Datasource -ProtectionGroup $pg

      ForEach($ds in $dsList) {

        $line = $ds.PSInfo.Name

        $line += "  " + $ds.Name

        $line += "  " + $ds.State

        Write-Output $line

      }

    }

    • Marked as answer by ielverson Tuesday, February 8, 2011 10:57 PM
    Tuesday, February 1, 2011 1:56 AM
  • Thanks.  That helped.   One more question.  Where can I find a reference for the addressable attributes, like the Name and State of the data source?
    Tuesday, February 8, 2011 10:45 PM
  • "Get-Member" is very useful in determining what properties an object has:

     

    $pg | Get-Member

    $ds | Get-Member

    Again you should feed a single object to Get-Member, not an array of objects.  If you have an array of objects you can reference just one by using an index number like this:

    $dsList[0] | Get-Member

     

    Wednesday, February 9, 2011 1:57 PM
  • Thanks again.
    Wednesday, February 9, 2011 5:04 PM