VMware Horizon Community
Haroh
Contributor
Contributor

How to Add existing VMs in vCenter to Automated Pools in View 5?

Hi,

Is there any tool or way to add existing VMs in the vCenter to Automated pools?

We used to have this application that can do this on View 4.0 but it's not working on View 5.0

Help please.

Thanks Smiley Happy

Reply
0 Kudos
7 Replies
psplnalin123
Enthusiast
Enthusiast

I was not sure about VIew 4.0 because i Start working with View 4.6 and 5.0 Smiley Happy but not seen to add existing VMs to the Automated Pool I could be possible in Manual Pool but no option to be add into Automated Pool.

Why we want to add existing VMs to the automated Pool .

Also check one morething just coming in my mind could you select the Automated Pool then Full Virtual Machine and check are you getting the option to add the existing VMs

Reply
0 Kudos
Haroh
Contributor
Contributor

For View 4 we have a tool called PSO Import Tool for VMware VDM.

Sometimes we need to remove a Full cloned VM from a pool for maintenance purposes, v4.0 dont have the option to place a VM to maintenance mode, then  we use the tool to reimport it back to the pool.

Reply
0 Kudos
gunnarb
Expert
Expert

It wouldn't be an "automated" pool if it allowed non-automated VMs to be imported into it.  Automated implies Provisioning (Composer).  Any existing VM would need to be a part of a manual pool.

Hope this helps.

Gunnar

Gunnar Berger http://www.gunnarberger.com http://www.endusercomputing.com
Reply
0 Kudos
Haroh
Contributor
Contributor

In View 4.0, we are allowed to add VMs to "automated' pools manually when we have to.

And we dont use Composer and Linked-Clones on our Automated pools.

Reply
0 Kudos
gunnarb
Expert
Expert

Well, poop on me.  Okay, if its doable in 4, I'll do more digging then and see if its doable in 5.  PowerCLI here I come!

Gunnar Berger http://www.gunnarberger.com http://www.endusercomputing.com
Reply
0 Kudos
Haroh
Contributor
Contributor

I found this sample script in the PowerCLI documentation for View4.5.

I tried it but it's not working though.

# AddRemoveVMs.ps1
# Functions for adding and removing VMs in View Pools.
# WARNING: These functions manipulate the ADAM directory directly, which may cause faults in an environment if used incorrectly.
#### Add a VM to a pool
#### Parameters:
#### $VMObject:Virtual Machine object for VM to be added (obtained from Get-DesktopVM)
#### $pool_id:Name of pool to which VMObject should be added
#### Example Usage: AddVMToPool (Get-DesktopVM -Name <vmname>) <pool_id>
function AddVMToPool
{ param ($VMObject, $pool_id)
if($VMObject.vm)
{
   if($VMObject.isInPool -eq “true”)
      {
    Write-Error (“The specified VM (“ + $VMObject.Name + “) is already assigned to a pool.”)
      }
   else
      {
    # Get the GUID for this VM’s entry in ADAM, creating an entry if necessary
    $machine_id = $VMObject.machine_id
    if(-not $machine_id)
        {
     $machine_id = AddVMToADAM $VMObject
        }
    # Locate the server group for the pool to which this VM belongs
$poolObject = [ADSI](“LDAP://localhost:389/cn=” + $pool_id + “,ou=Applications,dc=vdi,dc=vmware,dc=int”)
    $serverGroup =  [ADSI](“LDAP://localhost:389/” + $poolObject.get(“pae-Servers”)) 
    # Add the distinguished name of the VM’s ADAM entry to the server group
    if($serverGroup)
        {
      $machineName = $VMObject.Name
$serverGroupId = $serverGroup.get(“cn”)
      Write-Output (“Adding $machineName to pool $pool_id”)
                              $machineList = &
{
                trap [Exception]
        { continue;
                   }
      $serverGroup.get(“pae-MemberDN”) 
          }
            if($machineList)
        {
             if($machineList.Count -gt 1)
          {
               $machineListAL = New-Object System.Collections.ArrayList(,$machineList)
          }
      else
          {
               $machineListAL = New-Object System.Collections.ArrayList
               $null = $machineListAL.add($machineList)
               }
         }
   else
    {
            $machineListAL = New-Object System.Collections.ArrayList
            }
$null = $machineListAL.Add(“CN=” + $machine_id + “,ou=Servers,dc=vdi,dc=vmware,dc=int”)
    $serverGroup.put(“pae-MemberDN”,$machineListAL.ToArray())
      $serverGroup.SetInfo()
        }
      }
}
else
{
Write-Error “The object passed as a parameter was not a valid VM object (a valid
object would be returned by Get-DesktopVM).”
}
}
Reply
0 Kudos
gunnarb
Expert
Expert

Okay I'd need to work in an environment that has this but I'd start by cherry picking some of these commands and seeing what PowerCLI allows.

Get-ViewVC -serverName vc.mydom.int | Add-AutomaticPool -pool_id auto1 -displayName "ADP1" -namePrefix "adp1-{n:fixed=4}" -vmFolderPath /AutoConfig/vm -resourcePoolPath /AutoConfig/host/Resources -templatePath /AutoConfig/vm/ADP_template -dataStorePaths /host/datastore_1/lun10 -customizationSpecName "Windows 7 Variation 3" -minimumCount 4 -maximumCount 10

this is right out of the PowerCLI admin guide, and won't do what you ask, but it has a lot of good information in htere.

Gunnar

Gunnar Berger http://www.gunnarberger.com http://www.endusercomputing.com
Reply
0 Kudos