mrray
Enthusiast
Enthusiast

Get cluster and ID per data store

Hi,

I am trying to write a script that lists the data store name, the cluster it belong to and the ID in a format that looks about like this:

CLUSTERNAME     DATASTORE_NAME    naa.xyz123xxxxxxxxxxxxxxxxxxxxxxxxxxxxx

 

I poked around and found 2 scripts that do each of the parts, but I cannot figure out how to merge them, so so speak.

 

Data store and cluster name:

 

Get-Cluster -PipelineVariable cluster |

Get-Datastore |

select @{N='Cluster';E={$cluster.Name}}Name, Type, FilesystemVersion, State, Accessible | Out-GridView

 

Get data store name and ID:

 

Get-Datastore | where{$_.Type -eq 'VMFS'} |

Select Name,

    @{N='LUN';E={$_.ExtensionData.Info.Vmfs.Extent.DiskName -join ' | '}}

 

Now, can anyone explain how I merge these, getting the

 

@{N='LUN';E={$_.ExtensionData.Info.Vmfs.Extent.DiskName -join ' | '}}

 

to be part of the first script?

5 Replies
LucD
Leadership
Leadership

You could just copy that calculated property to the 1st script

Get-Cluster -PipelineVariable cluster |

Get-Datastore |

select @{N='Cluster';E={$cluster.Name}},Name, Type, FilesystemVersion, State, Accessible,

     @{N='LUN';E={$_.ExtensionData.Info.Vmfs.Extent.DiskName -join ' | '}}


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

0 Kudos
mrray
Enthusiast
Enthusiast

I must have placed the value wrong somehow.

Anyways, that works like a charm 🙂

Thanks.

0 Kudos
AlbertWT
Virtuoso
Virtuoso

Would it be possible to show the Disk space size in total for each VMFS datastore?

/* Any kind of comment or input would be greatly appreciated */
0 Kudos
LucD
Leadership
Leadership

Do you mean the capacity, like this?

Get-Cluster -PipelineVariable cluster |

Get-Datastore |

select @{N='Cluster';E={$cluster.Name}},Name, Type, CapacityGB,FilesystemVersion, State, Accessible,

     @{N='LUN';E={$_.ExtensionData.Info.Vmfs.Extent.DiskName -join ' | '}}


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

AlbertWT
Virtuoso
Virtuoso

Thank you, Luc, for the assistance in this matter.

/* Any kind of comment or input would be greatly appreciated */
0 Kudos