Wednesday, January 19, 2011

setting multiple swapfile datastores on a host question

hello,

I'm trying to automate -vmswapdatastore location on my cluster and so far I managed to add single datastore that can be used. Problem is i can't figure out how to add multiple datastores that are allocated to swapfile datstores on my cluster.

here is my code:

connect-viserver vcenter

foreach ($vmhost in get-cluster "clustername" | get-vmhost)

{ Get-vmhost $vmhost | set-vmhost -vmswapfiledatastore "VS01" }

this works perfectly but I can't add more of them and if i try to add another one it just replaces the current one with new one. so how would i go about adding vs02 and vs03 to the datstores?

What is the trick to doing this?

thanks

  • rather than { Get-vmhost $vmhost | set-vmhost -vmswapfiledatastore "VS01" }, could you not use different data store names, to make it easier to script?

    eg: { Get-vmhost $vmhost | set-vmhost -vmswapfiledatastore "VS-$vmhost" }

    saves you having to bother counting how many machines are running, or which ones is using what datastore.

    I'm probably completely off the mark and missed the point, but...

0 comments:

Post a Comment