Warning: Windows NFS server is not listed on VMWare HCL as Esxi NFS datastore. I am using it as a demo purpose.
In this article I will use NFS mount created earlier in Microsoft Powershell: Windows 2016 Install and configure NFS server. Mounting the same NFS Datastore storage on Esxi servers or cluster using vSphere PowerCLI, It is best way to automate and make it task easy. All the tasks are performed using command lines only.
First simple one-liner command to add Nfs storage is as below. It will add datastore on one esxi host at a time, You can use multiple esxi host name separating comma (,), or use the command using different esxi host names as shown in the screenshot.
Get-VMHost esxi001.vcloud-lab.com | New-Datastore -Nfs -Name nfs01 -Path /nfs01 -NfsHost 192.168.34.11
To verify datastore is mounted correctly use command.
Get-VMHost esxi001.vcloud-lab.com | Get-Datastore
To know and verify Nfs Datastore is mounted on which esxi servers use,
Get-Datastore nfs01 | Get-VMHost
Here in next task you might need to remove datastore from esxi server, first make sure There are no VMs exist on the storage and no dependency, use. No results are showing means no VMs on the datastore.
Get-Datastore nfs01 | Get-VM
After confirming no VMs present, use below command to unmount NFS datastore from multiple esxi servers.
Get-VMHost esxi001.vcloud-lab.com, esxi002.vcloud-lab.com | Remove-Datastore -Datastore nfs01 -Confirm:$false
Earlier I used single ESXi servers to mount NFS datastore, Below command mounts/add storage on all esxi servers in Cluster.
Get-Cluster Cluster01 | Get-VMHost | New-Datastore -Nfs -Name nfs01 -Path /nfs01 -NfsHost 192.168.34.11
Same way I am removing datastore from a cluster instead individual ESXi.
Get-Cluster Cluster01 | Get-VMHost | Remove-Datastore -Datastore nfs01
To verify NFS datastore not exists in the vCenter or a Cluster, I am fetching datastore result from all esxi servers in the Cluster, NFS datastore is not listed here.
Get-Cluster | Get-VMHost | Get-Datastore
Earlier useful posts
Mount NFS share to multiple ESXi hosts
VMWare ESXi add and create NFS datastore
Microsoft Windows 2016 Install and configure NFS server for ESXi and Linux
Unmount NFS datastores from VMware ESXi and NFS is in use
This post first appeared on Tales From Real IT System Administrators World And Non-production Environment, please read the originial post: here