11 Replies Latest reply on Jun 11, 2019 11:41 AM by haripadmam

    Script to get infomration of datastore per cluster

    AnkurS11 Novice

      Hi All,


      Good Morning!


      I am trying to write a script to get all datastore in the cluster and it should give me the data in table format like datastorename, clustername,capacityGB, freespaceGB,usedspace=freespaceGB/capacityGB *100


      #$VCName = Read-Host "Enter the VC name "

      Connect-VIServer VCname -WarningAction Continue


      $cls = get-cluster

      Get-Datastore|where {$_.name -notlike "*local*" -and $_.name -notlike "*template*"}| Format-Table name ,capacityGB, freespaceGB -AutoSize


      the above get-datastore cmd is giving me the list of all the datastore and capacityGB, freespaceGB but not the cluster name. I tried for loop as well but not getting the desired result.


      Can someone correct my script above.