VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot

blank output

Hi,

I am getting the blank output from the below script, please help

Function Get-SrmConfigReportProtectedDatastore {

    Param(

        [VMware.VimAutomation.Srm.Types.V1.SrmServer] $SrmServer

    )

    Get-SrmProtectionGroup -SrmServer $SrmServer -Type "san" | %{

        $pg = $_

        $pginfo = $pg.GetInfo()

        $pds = Get-SrmProtectedDatastore -ProtectionGroup $pg

        $pds | %{

            $pd = $_

            $output = "" | select datacenter, group, name, capacity, free

            $output.datacenter = $pd.Datacenter.Name

            $output.group = $pginfo.Name

            $output.name = $pd.Name

            $output.capacity = $pd.CapacityGB

            $output.free = $pd.FreeSpaceGB

            $output

        }

    } | Format-Table -Wrap -AutoSize -GroupBy "datacenter" @{N="Datastore Name"; E={$_.name} },

                                   @{N="Capacity GB"; E={$_.capacity} },

                                   @{N="Free GB"; E={$_.free} },

                                   @{N="Protection Group"; E={$_.group} }

}

Get-SrmConfigReportProtectedDatastore

Output

Datastore Name Capacity GB Free GB Protection Group

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

                                   1_GrpMgmt

0 Kudos
7 Replies
LucD
Leadership
Leadership

You don't seem to be passing any value on the SrmServer parameter when calling the function.

While the function does do use the SrmServer parameter, with an empty value in this case, in it's call to Get-SrmProtectionGroup.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
ganapa2000
Hot Shot
Hot Shot

LucD,

I have connected to SRM Server and gave the command as below

Get-SrmConfigReportProtectedDatastore $srmserver

still the same output

0 Kudos
LucD
Leadership
Leadership

After you connected, did you try

Get-SrmProtectionGroup -Type "san"

Was anything returned?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
ganapa2000
Hot Shot
Hot Shot

LucD,

Below is the output for Get-SrmProtectionGroup -Type "san"

Name                MoRef
----                -----

1_Prod1     SrmProtectionGroup-srm-vm-protection-group-462813

2_Prod2   SrmProtectionGroup-srm-vm-protection-group-463585
0_DR1     SrmProtectionGroup-srm-vm-protection-group-488012
3_Prod2  SrmProtectionGroup-srm-vm-protection-group-490511
0 Kudos
LucD
Leadership
Leadership

I'm not sure why you have the Format-Table in the function.

Can you try to change the function to

Function Get-SrmConfigReportProtectedDatastore {

   Param(

   [VMware.VimAutomation.Srm.Types.V1.SrmServer] $SrmServer

   )


   Get-SrmProtectionGroup -SrmServer $SrmServer -Type "san" | %{

   $pg = $_

   $pginfo = $pg.GetInfo()

   $pds = Get-SrmProtectedDatastore -ProtectionGroup $pg

   $pds | %{

   $pd = $_

   $output = "" | select datacenter, group, name, capacity, free

   $output.datacenter = $pd.Datacenter.Name

   $output.group = $pginfo.Name

   $output.name = $pd.Name

   $output.capacity = $pd.CapacityGB

   $output.free = $pd.FreeSpaceGB

   $output

   }

   }

}

If you want the output formatted in table format, you can do this by piping the output of the function call to Format-Table.

Like this

Get-SrmConfigReportProtectedDatastore |

Format-Table -Wrap -AutoSize -GroupBy "datacenter" @{N="Datastore Name"; E={$_.name} },

   @{N="Capacity GB"; E={$_.capacity} },

   @{N="Free GB"; E={$_.free} },

   @{N="Protection Group"; E={$_.group} }


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
ganapa2000
Hot Shot
Hot Shot

LucD,

I am getting as below, still showing blank Smiley Sad

Datastore Name Capacity GB Free GB Protection Group

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

                                   1_Prod1

                                   2_Prod2

                                   2_Prod3

                                   0_DR4

                                  

datacenter :

group      : 1_Prod1

name       :

capacity   :

free       :

datacenter :

group      : 2_Prod2

name       :

capacity   :

free       :

datacenter :

group      : 2_Prod3

name       :

capacity   :

free       :

datacenter :

group      : 0_DR4

name       :

capacity   :

free       :

0 Kudos
LucD
Leadership
Leadership

When you run the code in the function separately, does it produce anything?

I have the impression that the Get-SrmProtectedDatastore doesn't return anything.

Get-SrmProtectionGroup -Type "san" | %{

   $pg = $_

   $pginfo = $pg.GetInfo()

   $pds = Get-SrmProtectedDatastore -ProtectionGroup $pg

   $pds | %{

   $pd = $_

   $output = "" | select datacenter, group, name, capacity, free

   $output.datacenter = $pd.Datacenter.Name

   $output.group = $pginfo.Name

   $output.name = $pd.Name

   $output.capacity = $pd.CapacityGB

   $output.free = $pd.FreeSpaceGB

   $output

   }

   }


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos