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.
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 vdi.vmware.int\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; vmware.view.broker
#
#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
add-pssnapin vmware.view.broker
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
"enable"
{#Toggle pool on
$objPool.Put("pae-Disabled","0")}
#Disable pool instruction set
"disable"
{#Disconnect active sessions in specified pool
get-remotesession | where {$_.pool_id -eq $pool} | send-sessiondisconnect#Disable pool
$objPool.Put("pae-Disabled","1")}
#Default switch option
Default
{write-host "***** Unknown value for action *****"
write-host ""
}
}
}
else
{Write-host "***** Please enter a valid Pool name *****"
exit
}
#Clear object values
$objPool.Setinfo()
$objPool.close()
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.
filter blog by author
filter blog by category
You've got questions. And we've got answers. Give Clearpath a shout and we'll get to you with an answer...fast.

Post new comment