Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.