Hi
I have a list of VM's, Resource Pools, CPU Share Level in the RP and, Memory Share Level forthe Resource Pools
Below is an example
$list contains
VmName | ResourcePool | CpuShare | MemShare |
---|
MyVM1 | Low Priority | Low | Low |
MyVM2 | Normal Priority | Normal | Normal |
MyVM3 | High Priority | High | High |
All the VM's exist within the same Cluster but, are not necessarily in the correct Resource Pool
All of the Resource Pools may not even exist
How can I check to see if a Resource Pool exists within the Cluster,
- if it doesn't, have it created with the correct CPU/Mem Share levels (no Custom Levels defined)
- Move the respective VM into it
What I've come up with is
$list = import-csv $BiggerListofVMDetails | select VmName, ResourcePool, CpuShare,MemShare
foreach ($item in $list) {
if ( (get-cluster $cluster | get-resourcepool | select Name) -ne $item.ResourcePool ) {
write "The RP does not exist in the Cluster, need to create it"
new-resourcepool -location $cluster -name $item.ResourcePool -CpuShareLevel $item.CpuShare -MemShareLevel $item.MemShare
write "the RP has been created, time to move the VM into it"
}
move-vm $item.VmName -destination $item.ResourcePool
}
Thanks