PoshCode Archive  Artifact [31ec10d70a]

Artifact 31ec10d70aa15208920ae6e00a87c01824d91ecf70bda842347c059f705e825b:

  • File FastNFS-PowerCLI.ps1 — part of check-in [1d2ebcd501] at 2018-06-10 13:15:03 on branch trunk — Mounts a NFS datastore to several vSphere 4.X hosts with PowerCLI. The script assumes you are already connected to a VI server. (user: eprich size: 1307)

# encoding: ascii
# api: powershell
# title: FastNFS - PowerCLI
# description: Mounts a NFS datastore to several vSphere 4.X hosts with PowerCLI. The script assumes you are already connected to a VI server.
# version: 0.1
# type: script
# author: eprich
# license: CC0
# x-poshcode-id: 2735
# x-archived: 2011-06-17T15:08:23
# x-published: 2011-06-14T12:01:00
#
#
# fastNFS
# Description: Mounts NFS datastore to a group of ESX hosts.
# Usage: Enter a list of ESX hosts (by IP or hostname). Then enter the IP, path, and datastore name of the share.
#
#
# Enter the name or IP of the NFS server
$nfssrv = Read-Host "Enter the name or IP of the NFS server"
 
# Enter the full path to the share
$nfspath = Read-Host "Enter the full path to the share"
 
# Give a name for the new NFS datastore
$nfsds = Read-Host "Enter a name for the new NFS datastore"
 
# Create an empty array for $esx
$esx = @()
 
# Will continue to prompt for ESX hosts until you stop entering them.
do {
    $input = Read-Host "Add an ESX host by FQDN or IP"
    if ($input -ne ""){
        $esx += $input
    }
   }
until ($input -eq "")
 
# Mounts the datastore
foreach ($name in $esx)
        {
        New-Datastore -VMHost $name -Name $nfsds -Path $nfspath -Nfshost $nfssrv -Nfs
        }