rxjoseph
Enthusiast
Enthusiast

Get Datastore information

Jump to solution

Hi LucD

I have put a simple script to collect all datastore information 

The script collecting the Datastore information is working ok however i need to get the Cluster names as well 

The issue i have here is I am getting all the cluster names in an array so its incorrect. How can i get the respective cluster name for the storage please 

 

Get-cluster |Get-Datastore |Select-Object ` @{N="Cluster" ;E={Get-cluster |select $($_name)}}, ` @{N="Datastore_Name"; E={$_.name}}, ` @{N="CapacityGB" ; E={[Math]::Round($_.CapacityGB)}},` @{N="FreeSpaceGB" ; E={[Math]::Round($_.FreeSpaceGB)}}, ` @{N="Freespace%" ; E={[Math]::Round($_.FreespaceGB/$_.CapacityGB *100) }}

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

You could use the PipelineVariable

Get-cluster -PipelineVariable cluster  |Get-Datastore |
Select-Object @{N="Cluster" ;E={$cluster.Name}},
    @{N="Datastore_Name"; E={$_.name}},
    @{N="CapacityGB" ; E={[Math]::Round($_.CapacityGB)}},
    @{N="FreeSpaceGB" ; E={[Math]::Round($_.FreeSpaceGB)}},
    @{N="Freespace%" ; E={[Math]::Round($_.FreespaceGB/$_.CapacityGB *100) }}


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

View solution in original post

2 Replies
LucD
Leadership
Leadership

You could use the PipelineVariable

Get-cluster -PipelineVariable cluster  |Get-Datastore |
Select-Object @{N="Cluster" ;E={$cluster.Name}},
    @{N="Datastore_Name"; E={$_.name}},
    @{N="CapacityGB" ; E={[Math]::Round($_.CapacityGB)}},
    @{N="FreeSpaceGB" ; E={[Math]::Round($_.FreeSpaceGB)}},
    @{N="Freespace%" ; E={[Math]::Round($_.FreespaceGB/$_.CapacityGB *100) }}


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

rxjoseph
Enthusiast
Enthusiast

Thank you LucD

The solution worked well

Appreciate your help

Many thanks

RXJ

0 Kudos