Automation

 View Only
  • 1.  Find shared datastore names in vcenter under different clusters

    Posted May 23, 2020 02:55 PM

    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.



  • 2.  RE: Find shared datastore names in vcenter under different clusters

    Posted May 23, 2020 03:07 PM

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

    }



  • 3.  RE: Find shared datastore names in vcenter under different clusters

    Posted May 24, 2020 03:15 PM

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

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



  • 4.  RE: Find shared datastore names in vcenter under different clusters
    Best Answer

    Posted May 24, 2020 04:09 PM

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

    }