Clearpath’s Blog on IT Infrastructure, Hybrid Clouds and IT Security

Disable VMware View Pool using Powershell PowerCLI

Posted by Rob Daniels on Mon, Jan 23, 2012 @ 07:23 PM

Have you ever wanted to disable a VDI pool from the command line, but couldn’t find the right command for the job? As simple as it may seem to do, VMware has yet to equip the PowerCLI Snap-in with a “disable-pool” commandlet. Some may try to accommodate this by simply removing pool entitlements, but you can be faced with the following error:

Remove-PoolEntitlement : PowershellService::RemovePoolEntitlement FAILED, 
error=User with sid  has an active VDI Session on Pool . Entitlement cannot be 
removed until this session is terminated.

Contact Clearpath's VMware Licensing and Professional Services Team

This error is the result of an active desktop session attached to the entitlement being removed, or worse, anywhere within the VDI system as this is a global property. What this means is that if a user has an entitlement to more than one pool, this command may fail every time. As a work-around, there is a value within the local ADAM database on the View broker server. It is a Boolean value with the name “pae-Disabled” and can be found in the\Applications\ attribute of the local LDAP. Below is an example of how this value can be toggled from a script:

#Script takes parameters for pool name and action.
#Outcome is an enabled/disabled pool.
#Active sessions are disconnected before disabling.
#Dependencies: activedirectory module;
#Parameters (toggle-view_pool.ps1 -pool [poolname] –action [enable|disable])
#-pool: specifies the pool name
#-action: specifies the action imposed on the pool
param([string]$action = "", [string]$pool = "")
#Add Snapins/Modules
import-module activedirectory
#Connect to View ADAM database
$objPool = [ADSI]"LDAP://localhost/cn=$pool, ou=Applications, dc=vdi, dc=vmware, dc=int"
#Test if pool exists
if ($objPool)
      switch ($action)
            #Enable pool instruction set
                        #Toggle pool on
            #Disable pool instruction set
                        #Disconnect active sessions in specified pool
                        get-remotesession | where {$_.pool_id -eq $pool} | send-sessiondisconnect
                        #Disable pool
                  #Default switch option
                              write-host "***** Unknown value for action *****"
                              write-host ""
      Write-host "***** Please enter a valid Pool name *****"
#Clear object values

This script can be run from any scheduler by adding a PowerShell directive (powershell toggle-view_pool.ps1 -pool [poolname] –action [enable|disable]). As of this writing, toggling the “pae-Disabled” value is the only known method of successfully disabling pools from the command line. Let us know if you have tackled this using a different approach.

Topics: VMware, VMware View

Subscribe to Email Updates

Recent Posts

Posts by Topic

see all
Live Chat Support Software