I am deploying about 135 VM's from a single template using powercli from a CSV file.
Each line in the CSV has a login, course, section, instructor
Example...
Login Course Section Instructor
123456 EE123 5555 Foo
Here is the script
I am trying to make the datastore a little cleaner when I deploy these machines, and put all the machines in a folder located in the datastore eg. datastore1\spring2013\EE123\ (would actually like to have $Course in place of EE123)
Can someone help me out with this.
Thanks in advance
Yes, you can use the ResourcePool parameter on the New-VM cmdlet for that.
But since you have resourcepools with the same name in the tree structure, you will have to make sure you select the correct one.
You use the Location parameter to indicate which branch in the tree you want.
For example:
$rpRoot = Get-ResourcePoo -Name "Sprint 2013"
$rpCourse = Get-ResourcePoo -Name "5555 Foo" -Location $rpRoot
$rpServers = Get-ResourcePoo -Name "Servers" -Location $rpCourse
$rpStudents = Get-ResourcePoo -Name "Students" -Location $rpCourse
New-VM -Name .... -ResourcePool $rpStudents
You can build this logic into a loop and use the names from a CSV file for example
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Afaik there is no cmdlet available in the current release that allows you to do such a thing.
In fact the VirtualMachineRelocateSpec object, which controls the CloneVM_Task method, only foresees a datastore for the new VM.
That is the SDK API that is used internally by the New-VM cmdlet for cloning a VM from a template.
The only way I can think of to do this would be something like this
But I'm not sure if nesting folders like that on a datastore is a "best practice".
I would go for dedicated folders under the VM and Templates view in the vCenter.
Then you would still have the folder organisation, not on the datastore but in the vCenter.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That is pretty much what I was thinking, but it seems like too much work to go through to organize the datastore only for my benefit. I do have another question though. In my script, my resource pool is something like "5555 Foo". Would it be possible to add the new machine to a nested resource pool (child resource pool). Ex. I have resource pools like this
Sprint 2013
1111 Smith
Servers
Students
3333 Bar
Servers
Students
5555 Foo
Servers
Students
I would be using resource pools only for organization, and not changing any of the setting when it is created. I am sure this isn't "best practices" but I like organization. Right now my script will put the new machine at the 5555 Foo. It would be nice to have it go directly into the Students.
Is this possible? Does that make sense?
Thanks again
Yes, you can use the ResourcePool parameter on the New-VM cmdlet for that.
But since you have resourcepools with the same name in the tree structure, you will have to make sure you select the correct one.
You use the Location parameter to indicate which branch in the tree you want.
For example:
$rpRoot = Get-ResourcePoo -Name "Sprint 2013"
$rpCourse = Get-ResourcePoo -Name "5555 Foo" -Location $rpRoot
$rpServers = Get-ResourcePoo -Name "Servers" -Location $rpCourse
$rpStudents = Get-ResourcePoo -Name "Students" -Location $rpCourse
New-VM -Name .... -ResourcePool $rpStudents
You can build this logic into a loop and use the names from a CSV file for example
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That is awesome. Thank you very much.