VMware Cloud Community
NWolford51
Contributor
Contributor
Jump to solution

DatastoreCluster Reporting

Hey all,

Is it possible to report on all the datastores that are in the cluster?  For instance, we have a Datastore Cluster that has 16 datastores inside of it.  I want to traverse by each cluster and get results for the entire Datastore Cluster and not each individual datastore.  This is what I have been using but it returns every single datastore. 

javascript:;Get-Datastore  |

Select @{N='Datacenter';E={$_.Datacenter.Name}},

    @{N='DSC';E={Get-DatastoreCluster -Datastore $_ | Select -ExpandProperty Name}},

    Name,CapacityGB,@{N='FreespaceGB';E={[math]::Round($_.FreespaceGB,2)}},

    @{N='ProvisionedSpaceGB';E={[math]::Round(($_.ExtensionData.Summary.Capacity - $_.Extensiondata.Summary.FreeSpace + $_.ExtensionData.Summary.Uncommitted)/1GB,2)}},

    @{N='UnCommittedGB';E={[math]::Round($_.ExtensionData.Summary.Uncommitted/1GB,2)}},

    @{N='VM';E={$_.ExtensionData.VM.Count}} | Format-Table -AutoSize

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Something like this?

Get-Datacenter -PipelineVariable dc |

Get-DatastoreCluster -PipelineVariable dsc |

ForEach-Object -Process {

    $ds = Get-Datastore -RelatedObject $dsc

    '' | Select @{N='Datacenter';E={$dc.Name}},

        @{N='DSC';E={$dsc.Name}},

        @{N='CapacityGB';E={($ds | Measure-Object -Property CapacityGB -Sum).Sum}},

        @{N='ProvisionedSpaceGB';E={

            [math]::Round((($ds.ExtensionData.Summary.Capacity | Measure-Object -Sum).Sum -

            ($ds.Extensiondata.Summary.FreeSpace | Measure-Object -Sum).Sum +

            ($ds.ExtensionData.Summary.Uncommitted | Measure-Object -Sum).Sum)/1GB,2)}},

        @{N='UnCommittedGB';E={[math]::Round(($ds.ExtensionData.Summary.Uncommitted | Measure-Object -Sum).Sum/1GB,2)}},

        @{N='VM';E={($ds.ExtensionData.VM.Count | Measure-Object -Sum).Sum}}

}


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

View solution in original post

15 Replies
NWolford51
Contributor
Contributor
Jump to solution

I am looking to report on the following of an all the datastores in a datastorecluster in each specific datacenter cluster:

Capacity, FreeSpace, VM's, PercentFree and UncomittedSpace

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try something like this

Get-DatastoreCluster -PipelineVariable dsc |

Get-Datastore  |

Select @{N='Datacenter';E={$_.Datacenter.Name}},

    @{N='DSC';E={$dsc.Name}}, 

    Name,CapacityGB,@{N='FreespaceGB';E={[math]::Round($_.FreespaceGB,2)}},

    @{N='ProvisionedSpaceGB';E={[math]::Round(($_.ExtensionData.Summary.Capacity - $_.Extensiondata.Summary.FreeSpace + $_.ExtensionData.Summary.Uncommitted)/1GB,2)}},

    @{N='UnCommittedGB';E={[math]::Round($_.ExtensionData.Summary.Uncommitted/1GB,2)}},

    @{N='VM';E={$_.ExtensionData.VM.Count}} | Format-Table -AutoSize


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

Reply
0 Kudos
NWolford51
Contributor
Contributor
Jump to solution

Thanks for the quick reply!

So, that is similar to what I was getting with my script.  I am trying to find a way to report on the cluster as a whole instead of each individual datastore.

Datacenter   DSC                                                                        Name                                                        CapacityGB     FreespaceGB    ProvisionedSpaceGB     UnCommittedGB VM

ANF              ANF-CUC01-PR_VPLEX0146-SG01-local            ANF_VPLEX0146_SG01_D89C_local     4095.75           1999.21             2473.14                           376.6 13

ANF              ANF-CUC01-PR_VPLEX0146-SG01-local            ANF_VPLEX0146_SG01_D89B_local     4095.75            2076.83            2574.81                            555.89 16

So, instead of reporting each individual name (ANF_VPLEX0146_SG01_D89C_local , ANF_VPLEX0146_SG01_D89B_local ) I would like to report on the DSC only (ANF-CUC01-PR_VPLEX0146-SG01-local).  Is that possible? 

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Something like this?

Get-Datacenter -PipelineVariable dc |

Get-DatastoreCluster -PipelineVariable dsc |

ForEach-Object -Process {

    $ds = Get-Datastore -RelatedObject $dsc

    '' | Select @{N='Datacenter';E={$dc.Name}},

        @{N='DSC';E={$dsc.Name}},

        @{N='CapacityGB';E={($ds | Measure-Object -Property CapacityGB -Sum).Sum}},

        @{N='ProvisionedSpaceGB';E={

            [math]::Round((($ds.ExtensionData.Summary.Capacity | Measure-Object -Sum).Sum -

            ($ds.Extensiondata.Summary.FreeSpace | Measure-Object -Sum).Sum +

            ($ds.ExtensionData.Summary.Uncommitted | Measure-Object -Sum).Sum)/1GB,2)}},

        @{N='UnCommittedGB';E={[math]::Round(($ds.ExtensionData.Summary.Uncommitted | Measure-Object -Sum).Sum/1GB,2)}},

        @{N='VM';E={($ds.ExtensionData.VM.Count | Measure-Object -Sum).Sum}}

}


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

NWolford51
Contributor
Contributor
Jump to solution

LucD,

Thank you.  THat is exactly where I was trying to go with it.  Appreciate your help.

Reply
0 Kudos
NWolford51
Contributor
Contributor
Jump to solution

One final question, is it possible to get this in a table with only one header and all the datastore clusters reported underneath that one header?  Right now they each have their own individual header.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Not sure I'm following.
Can you show what you see and what you would like to see?


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

Reply
0 Kudos
NWolford51
Contributor
Contributor
Jump to solution

We are pulling the correct information now:

Datacenter DSC                                CapacityGB ProvisionedSpaceGB UnCommittedGB VM

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

ANF        ANF-CORP01-PR_VPLEX0146-SG01-local     8191.5            5673.96       4027.98 19

Datacenter DSC                             CapacityGB ProvisionedSpaceGB UnCommittedGB VM

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

ANF        ANF-OCP-PR_VPLEX0146-SG01-local     8191.5            8799.54       4524.36 51

Datacenter DSC                                CapacityGB ProvisionedSpaceGB UnCommittedGB VM

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

ANF        ANF-CORP03-PR_VPLEX0146-SG01-local    16383.5           17313.76       7463.81 95

Datacenter DSC                                CapacityGB ProvisionedSpaceGB UnCommittedGB  VM

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

ANF        ANF-CORP02-PR_VPLEX0146-SG01-local      98300          106395.87      36365.22 608

But is it possible to format it like below:

Datacenter DSC                                CapacityGB ProvisionedSpaceGB UnCommittedGB VM

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

ANF        ANF-CORP01-PR_VPLEX0146-SG01-local     8191.5            5673.96       4027.98 19

ANF        ANF-OCP-PR_VPLEX0146-SG01-local     8191.5            8799.54       4524.36 51

ANF        ANF-CORP03-PR_VPLEX0146-SG01-local    16383.5           17313.76       7463.81 95

ANF        ANF-CORP02-PR_VPLEX0146-SG01-local      98300          106395.87      36365.22 608

That way the header is on the top line and then ll data below that.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Ok, try like this

$report = @()

Get-Datacenter -PipelineVariable dc |

Get-DatastoreCluster -PipelineVariable dsc |

ForEach-Object -Process {

    $ds = Get-Datastore -RelatedObject $dsc

    $report += '' | Select @{N='Datacenter';E={$dc.Name}},

        @{N='DSC';E={$dsc.Name}},

        @{N='CapacityGB';E={($ds | Measure-Object -Property CapacityGB -Sum).Sum}},

        @{N='ProvisionedSpaceGB';E={

            [math]::Round((($ds.ExtensionData.Summary.Capacity | Measure-Object -Sum).Sum -

            ($ds.Extensiondata.Summary.FreeSpace | Measure-Object -Sum).Sum +

            ($ds.ExtensionData.Summary.Uncommitted | Measure-Object -Sum).Sum)/1GB,2)}},

        @{N='UnCommittedGB';E={[math]::Round(($ds.ExtensionData.Summary.Uncommitted | Measure-Object -Sum).Sum/1GB,2)}},

        @{N='VM';E={($ds.ExtensionData.VM.Count | Measure-Object -Sum).Sum}}

}

$report


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

Reply
0 Kudos
NWolford51
Contributor
Contributor
Jump to solution

That changed the formatting to more of a list structure.  I tried to add "| Format_Table -Autosize" to the end but each Datastore Cluster still had its own header.

Datacenter         : ANF

DSC                : ANF-ECOM02-PR_VPLEX0146-SG01-local

CapacityGB         : 8191

ProvisionedSpaceGB : 557.21

UnCommittedGB      : 76.15

VM                 : 1

Datacenter         : ANF

DSC                : ANF-DMZ01-PR_VPLEX0146-SG01-local

CapacityGB         : 8191.5

ProvisionedSpaceGB : 10105.74

UnCommittedGB      : 4657.87

VM                 : 74

Datacenter         : ANF

DSC                : ANF-CUC01-PR_VPLEX0146-SG01-local

CapacityGB         : 8191.5

ProvisionedSpaceGB : 5047.79

UnCommittedGB      : 932.49

VM                 : 29

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

The format you see on screen is determined by many factors.

In this case, the fact that there are more than 5 properties made the PowerShell output formatter decide to go for the Format-List format.

Not sure where you added the Format-Table, but this seems to work for me.

$report = @()

Get-Datacenter -PipelineVariable dc |

Get-DatastoreCluster -PipelineVariable dsc |

ForEach-Object -Process {

    $ds = Get-Datastore -RelatedObject $dsc

    $report += '' | Select @{N='Datacenter';E={$dc.Name}},

        @{N='DSC';E={$dsc.Name}},

        @{N='CapacityGB';E={($ds | Measure-Object -Property CapacityGB -Sum).Sum}},

        @{N='ProvisionedSpaceGB';E={

            [math]::Round((($ds.ExtensionData.Summary.Capacity | Measure-Object -Sum).Sum -

            ($ds.Extensiondata.Summary.FreeSpace | Measure-Object -Sum).Sum +

            ($ds.ExtensionData.Summary.Uncommitted | Measure-Object -Sum).Sum)/1GB,2)}},

        @{N='UnCommittedGB';E={[math]::Round(($ds.ExtensionData.Summary.Uncommitted | Measure-Object -Sum).Sum/1GB,2)}},

        @{N='VM';E={($ds.ExtensionData.VM.Count | Measure-Object -Sum).Sum}}

}

$report | Format-Table -AutoSize


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

NWolford51
Contributor
Contributor
Jump to solution

Yes, that works perfectly.  I had it on the last line of code and not behind the $report.  Thanks again LucD!

Reply
0 Kudos
vmk2014
Expert
Expert
Jump to solution

LucD,

Sorry to bother you. While running the code, it gives me an error "missing closing ' ' in statement block or type definition" and empty pipeElement not allowed.

I'm trying to export into csv.

At D:\abc\DatastoreCluster Reporting.ps1:27 char:10

+          | Export-Csv -path c:\Temp\DataStoreClusterStatus.csv -NoTyp ...

+          ~

An empty pipe element is not allowed.

At D:\abc\DatastoreCluster Reporting.ps1:5 char:25

+ ForEach-Object -Process {

+                         ~

Missing closing '}' in statement block or type definition.

    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException

    + FullyQualifiedErrorId : EmptyPipeElement

Your help is much appreciated.

Thanks

V

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

I'm not sure what you did, since you don't share the code, but that line seems to start with the pipeline symbol.

That should normally be at the end of the previous line.


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

Reply
0 Kudos
vmk2014
Expert
Expert
Jump to solution

LucD,

I'll open a new thread as you suggested in earlier mail thread.

Thanks

V

Reply
0 Kudos