vmk2014
Expert
Expert

Datastore Cluster usage reporting

Jump to solution

Hi All,

I'm trying to pull the Datastore cluster report usage, but it throws an error while running the code. I have used the code from earlier thread.

Also, i have tried to add missing braces, but still same error.

error :-

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

Code :

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}}

       

         | Export-Csv -path c:\Temp\DataStoreClusterStatus.csv -NoTypeInformation -UseCulture

Thanks in advance.

V

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

You forgot the include the closing brace for the Foreach-Object process block.
The pipeline symbol after the process block should be on the same line as that closing curly brace.

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}}

} | Export-Csv -path c:\Temp\DataStoreClusterStatus.csv -NoTypeInformation -UseCulture


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

View solution in original post

0 Kudos
1 Reply
LucD
Leadership
Leadership

You forgot the include the closing brace for the Foreach-Object process block.
The pipeline symbol after the process block should be on the same line as that closing curly brace.

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}}

} | Export-Csv -path c:\Temp\DataStoreClusterStatus.csv -NoTypeInformation -UseCulture


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

View solution in original post

0 Kudos