VMware Cloud Community
Target10
Contributor
Contributor
Jump to solution

Datastore report with NFS export path specification

Hi all I have created a datastore report with specification to SCSI LUN ID and NFS export path.

But I have no idea to query the NFS export path of a datastore. Can you help me in the following script?

$report = @()

$VMHost = Get-VMHost -Location

$cluster foreach($cluster in Get-Cluster){

      (Get-Datastore -VMHost $VMHost | where {$_.Type -eq "VMFS"}) | %{   

          $info = "" | select DataCenter, Cluster, Name, Capacity, Provisioned, Available, DSType, State, LUNid, NFSPath   

          $info.Datacenter = $_.Datacenter   

          $info.Cluster = $cluster.Name   

          $info.Name = $_.Name   

          $info.Capacity = [math]::Round($_.capacityMB/1024,2)   

          $info.Provisioned = [math]::Round(($_.ExtensionData.Summary.Capacity - $_.ExtensionData.Summary.FreeSpace + $_.ExtensionData.Summary.Uncommitted)/1GB,2)   

          $info.Available = [math]::Round($info.Capacity - $info.Provisioned,2)

          $info.DSType = $_.Type

          $info.State = $_.State

          $info.LUNid = Get-ScsiLun -Datastore $_

          $info.NFSPath = "n/a"     

          $report += $info

     }

     (Get-Datastore -VMHost $VMHost | where {$_.Type -eq "NFS"}) | %{   

          $info = "" | select DataCenter, Cluster, Name, Capacity, Provisioned, Available, DSType, State, LUNid, NFSPath   

          $info.Datacenter = $_.Datacenter   

          $info.Cluster = $cluster.Name   

          $info.Name = $_.Name   

          $info.Capacity = [math]::Round($_.capacityMB/1024,2)   

           $info.Provisioned = [math]::Round(($_.ExtensionData.Summary.Capacity - $_.ExtensionData.Summary.FreeSpace + $_.ExtensionData.Summary.Uncommitted)/1GB,2)   

          $info.Available = [math]::Round($info.Capacity - $info.Provisioned,2)

          $info.DSType = $_.Type

          $info.State = $_.State

          $info.LUNid = "n/a"

          $info.NFSPath = "I don't know"    

          $report += $info

     }

Thanks.

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
sneddo
Hot Shot
Hot Shot
Jump to solution

You can use the RemoteHost and RemotePath attributes of the datastore to get the path in whatever format you wish.

e.g. $info.NFSPath = "$($_.RemoteHost):/$($_.RemotePath)"  

View solution in original post

0 Kudos
2 Replies
sneddo
Hot Shot
Hot Shot
Jump to solution

You can use the RemoteHost and RemotePath attributes of the datastore to get the path in whatever format you wish.

e.g. $info.NFSPath = "$($_.RemoteHost):/$($_.RemotePath)"  

0 Kudos
Target10
Contributor
Contributor
Jump to solution

Thanks sneddo, that's it! Smiley Happy

0 Kudos