Mount nfs datastore to multiple hosts in a cluster: Difference between revisions
Jump to navigation
Jump to search
(Created page with " Category:vmware Category:vsphere Category:esxi Category:vcenter Category:vcsa Category:nfs") |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
This will get all the hosts in a cluster specified and mount the NFS datastore on all in the cluster. | |||
You can either copy and paste the below to a .ps1 file and run the file or run the commands manually. | |||
<pre> | |||
########################################################################################################################### | |||
# EDIT THESE | |||
########################################################################################################################### | |||
$vcenter = "vcenter01" # Change to the vCenter you wish to mount the NFS datastores to | |||
$dc = "datacenter01" # Change to datacenter name in vCenter | |||
$cluster = "cluster01" # Change to the cluster name you wish to mount the NFS datastores to | |||
$datastorename = "nfs-datastore01" # Change to name of datastore | |||
$nfshostip = "10.10.10.10" # Change to NFS host ip | |||
$nfspath = "nfs-datastore01-san01" # Change to NFS path | |||
########################################################################################################################### | |||
# DO NOT EDIT PAST THIS LINE | |||
########################################################################################################################### | |||
Connect-Viserver $vcenter | |||
$esxs = Get-Datacenter $dc | Get-Cluster $cluster | Get-VMHost | |||
foreach ($esx in $esxs){ | |||
$esx | New-Datastore -Nfs -Name $datastorename -NFSHost $nfshostip -Path $nfspath | |||
echo "NFS share added to $esx" | |||
} | |||
</pre> | |||
Line 8: | Line 35: | ||
[[Category:vcsa]] | [[Category:vcsa]] | ||
[[Category:nfs]] | [[Category:nfs]] | ||
[[Category:scripts]] | |||
<comments /> |
Latest revision as of 10:05, 20 March 2022
This will get all the hosts in a cluster specified and mount the NFS datastore on all in the cluster.
You can either copy and paste the below to a .ps1 file and run the file or run the commands manually.
########################################################################################################################### # EDIT THESE ########################################################################################################################### $vcenter = "vcenter01" # Change to the vCenter you wish to mount the NFS datastores to $dc = "datacenter01" # Change to datacenter name in vCenter $cluster = "cluster01" # Change to the cluster name you wish to mount the NFS datastores to $datastorename = "nfs-datastore01" # Change to name of datastore $nfshostip = "10.10.10.10" # Change to NFS host ip $nfspath = "nfs-datastore01-san01" # Change to NFS path ########################################################################################################################### # DO NOT EDIT PAST THIS LINE ########################################################################################################################### Connect-Viserver $vcenter $esxs = Get-Datacenter $dc | Get-Cluster $cluster | Get-VMHost foreach ($esx in $esxs){ $esx | New-Datastore -Nfs -Name $datastorename -NFSHost $nfshostip -Path $nfspath echo "NFS share added to $esx" }
<comments />