Pages: [1]
Print
Author Topic: Add NFS datastore on all ESX-hosts in cluster  (Read 3194 times)
KristianW
Newbie
*
Posts: 32


View Profile
« on: January 14, 2010, 09:18:23 AM »

Made a small script (with help from interweb) to add NFS datastore to all ESXhosts in cluster.

Code:
foreach
($ESXhost in get-cluster <CLUSTER>| get-vmhost

{

New-datastore ?nfs ?vmhost $ESXhost ?name <DATASTORENAME> ?path /<PATH> ?nfshost <NFSHOST>

}

#change <CLUSTER> to your clustername
#change <DATASTORENAME>, <PATH> and <NFSHOST> to desired settings.

NFSHOST can be ip-address or simply hostname


On a side note:
Anyone capable of adding some functionallity to the script?
I got 2 datacenters, with 3 clusters all together.

What I would like is an addon/fix - where I can do this with one script and three different settings for the individual clusters.
Logged
esarakaitis
Administrator
Sr. Member
*****
Posts: 256


8223109 sack57@hotmail.com littleking57 rootinfortwayne
View Profile WWW Email
« Reply #1 on: January 17, 2010, 02:47:19 PM »

try using the where-object function...

so where $cluster.name -eq "abc", do these settings
Logged
KristianW
Newbie
*
Posts: 32


View Profile
« Reply #2 on: January 26, 2010, 08:45:25 AM »

try using the where-object function...

so where $cluster.name -eq "abc", do these settings

Putting my head out here... Something like this??

Code:
foreach ($ESXhost in Get-Cluster | Get-VMHost
        where $cluster.name -eq "DEV"
                $Path="dd_dev"
                $NFSip="192.168.1.250"
        where $cluster.name -eq "TEST"
                $Path="dd_test"
                $NFSip="192.168.1.251"
        where $cluster.name -eq "Prod"
                $Path="dd_prod"
                $NFSip="192.168.1.252"
        {
        New-Datastore -Nfs -VMHost $ESXhost -Name $Path -Path /backup -NfsHost $NFSip
        }
 
Logged
esarakaitis
Administrator
Sr. Member
*****
Posts: 256


8223109 sack57@hotmail.com littleking57 rootinfortwayne
View Profile WWW Email
« Reply #3 on: January 26, 2010, 11:24:36 AM »

looks good, did it work? I'm guessing you'll need to increment $path
« Last Edit: January 26, 2010, 12:52:09 PM by esarakaitis » Logged
Pages: [1]
Print
Jump to: