VijayKumarMyada
Enthusiast
Enthusiast

Find shared datastore names in vcenter under different clusters

Jump to solution

Am trying to list shared datastores in between the clusters in vcenter

Get-Datastore | where{$_.ExtensionData.Summary.MultipleHostAccess} | select Name, Datacenter, Cluster, Host |ft -AutoSize

It is not giving the host-name and cluster name in which Datastore is shared so we can restrict the datastore only to the required cluster.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

Sure, try like this

Get-Datastore -PipelineVariable ds |

where{$_.ExtensionData.Summary.MultipleHostAccess} |

ForEach-Object -Process {

    $_.ExtensionData.Host |

    where{$_.MountInfo.Mounted} |

    Select @{N='Datatsore';E={$ds.Name}},

        @{N='DSC';E={(Get-DatastoreCluster -Datastore $ds).Name}},

        @{N='Datacenter';E={$ds.Datacenter}},

        @{N='Cluster';E={(Get-Cluster -VMHost (Get-View -Id $_.Key -Property Name).Name).Name}},

        @{N='VMHost';E={(Get-View -Id $_.Key -Property Name).Name}}

}


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

View solution in original post

0 Kudos
3 Replies
LucD
Leadership
Leadership

You could do something like this

Get-Datastore -PipelineVariable ds |

where{$_.ExtensionData.Summary.MultipleHostAccess} |

ForEach-Object -Process {

    $_.ExtensionData.Host |

    where{$_.MountInfo.Mounted} |

    Select @{N='Datatsore';E={$ds.Name}},

        @{N='Datacenter';E={$ds.Datacenter}},

        @{N='Cluster';E={(Get-Cluster -VMHost (Get-View -Id $_.Key -Property Name).Name).Name}},

        @{N='VMHost';E={(Get-View -Id $_.Key -Property Name).Name}}

}


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

0 Kudos
VijayKumarMyada
Enthusiast
Enthusiast

can i also add sDRS cluster name if datastores are part of sDRS.

Select @{N='Datatsore';E={$ds.ClusterName}},

0 Kudos
LucD
Leadership
Leadership

Sure, try like this

Get-Datastore -PipelineVariable ds |

where{$_.ExtensionData.Summary.MultipleHostAccess} |

ForEach-Object -Process {

    $_.ExtensionData.Host |

    where{$_.MountInfo.Mounted} |

    Select @{N='Datatsore';E={$ds.Name}},

        @{N='DSC';E={(Get-DatastoreCluster -Datastore $ds).Name}},

        @{N='Datacenter';E={$ds.Datacenter}},

        @{N='Cluster';E={(Get-Cluster -VMHost (Get-View -Id $_.Key -Property Name).Name).Name}},

        @{N='VMHost';E={(Get-View -Id $_.Key -Property Name).Name}}

}


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

View solution in original post

0 Kudos