Sunday, 1 May 2016

How to export NFS datastore information using PowerCLI?

Most of the time before Allocating new Datastores or increase space of Datastores or for Audit purpose, we need to find how much storage is allocated and what is the free space on all Datastores. We can see this easily from VI Client –> Datastores View.
Let’s see how we can export this information to csv using simple PowerCLI script.
Using below script you can export NFS datastores information like NFS server name or IP, Remote NFS volume path, Datastore Name, free space and total capacity of datastore.
#Connect vCenter server
#collect NFS datastore details
$nfsds = Get-VMHost | Get-Datastore | where { $_.Type -eq "nfs" -and $_.Accessible -eq "True"} | select Name, RemotePath, @{N="NFS"; E={[String]$_.RemoteHost}}, FreeSpaceGB, CapacityGB
#Export NFS datastore information to CSV file at C:\temp\nfs-ds.csv
$nfsds | Export-Csv -NoTypeInformation -path c:\temp\nfs-ds.csv


No comments:

Post a Comment