VMware Cloud Community
GaneshShastri
Enthusiast
Enthusiast

Need PowerCLI script for NFS DS to get Device Details.

Hello,

In our environment we are having NFS DS and it's totally full. When i check the report from vRops the Total Capacity is 4.7TB, Free Space is 1.01TB, Remaining Space 0% and Provisioned Space 11.8TB.

When i check with SAN team, they need information of Device.

Device Tab which they are looking in Home - Datastore and Datastores Clusters - Datacenter - In right side Datastore and Datastores Clusters Tab.

I need single script to get with DS name + Capacity + Free Space + Device information for DS in which the total capacity is < 70%.

I already tried with

Get-Datastore | Get-DatastoreMountInfo | Sort Datastore, VMHost | FT –AutoSize

I am not aware how to call Get-DatastoreMountInfo function in PowerCLI.

Regards

GaneshSS

5 Replies
vHaridas
Expert
Expert

$report = @()

foreach($cluster in Get-Cluster){
   
Get-VMHost -Location $cluster | Get-Datastore | %{
       
$info = "" | select DataCenter, Cluster, Name, Capacity, Provisioned, Available
       
$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)
       
$report += $info
    }
}

$report | Export-Csv "C:\cluster-ds.csv" -NoTypeInformation -UseCulture

Source - @LucD  - refer - PowerCli DataStore Audit?

Please consider awarding points for "Correct" or "Helpful" replies. Thanks....!!! https://vprhlabs.blogspot.in/
0 Kudos
GaneshShastri
Enthusiast
Enthusiast

Thanks Haridas for the reply.

I already get these information from vRops. Apart of it I need NAS Datastore Device Information details which is available in VC. I am attaching herewith Screen shot what info I required.

DeviceDetails.png

Regards

GaneshSS

0 Kudos
vHaridas
Expert
Expert

This will work -

PS C:\> $nfsds = Get-VMHost esxiHostname | Get-Datastore | where { $_.Type -eq "nfs" -and $_.Accessible -eq "True"} | select Name, RemotePath, @{N="NfsServer"; E={[String]$_.RemoteHost}}, FreeSpaceGB, CapacityGB

#Export Datstore information to CSV in c:\temp\nfs-ds.csv file

PS C:\> $nfsds | Export-Csv -NoTypeInformation -path c:\temp\nfs-ds.csv

#See the DS info on command line.

PS C:\> $nfsds

Thanks

Please consider awarding points for "Correct" or "Helpful" replies. Thanks....!!! https://vprhlabs.blogspot.in/
GaneshShastri
Enthusiast
Enthusiast

Hi Haridas

Thank you Haridas... It's working fine what i want. I will Message you again if anything is required.

Regards

GaneshSS

0 Kudos
vHaridas
Expert
Expert

Please mark it as correct/useful if this meets your requirements.

Please consider awarding points for "Correct" or "Helpful" replies. Thanks....!!! https://vprhlabs.blogspot.in/