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
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
LucD,
I have connected to SRM Server and gave the command as below
Get-SrmConfigReportProtectedDatastore $srmserver
still the same output
After you connected, did you try
Get-SrmProtectionGroup -Type "san"
Was anything returned?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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 |
I'm not sure why you have the Format-Table in the function.
Can you try to change the function to
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
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
LucD,
I am getting as below, still showing blank
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 :
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.
$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