VMware View Pool Entitelement Cleanup

When you unassign a VM from a user in VMware View pool, the user name not be deleted from “Pool Entitlement”,
If you checked “Enable Auto Assignment” in you pool settings and the user send a request to the pool, View will assign a new VM (Mostly spare VM) to the user, this is a misconfiguration.
You can delete users which don’t have VM on the pool for the pool entitlement by this script:

# By Davoud Teimouri v0.1
CLS #Clear screen
Write-Host("This script will clean your pool from unassigned users")
$PoolID=Read-Host ("Please enter PoolID") #Get PoolID from the user (Sometimes PoolID is same as pool name
$Users=Get-PoolEntitlement -pool_id $PoolID | Select-Object displayname #Query pool's users and store them to $Users
Foreach ($User in $USers)
    $RUser=$User.Substring(15) #Change this based on your domain name
    Write-Host ("Proccessing on: " + $RUser) -foregroundcolor "Green"
    $VM=Get-DesktopVM -pool_id $PoolID | Select-Object user_displayname | Where-Object {$_.user_displayname -eq $User}
    If ($VM -eq $Null)  {
        Get-User -name $RUser | Where-Object {$_.displayname -eq $user} |Remove-PoolEntitlement -pool_id $PoolID | Out-Null
        Write-Host ($User + " has been removed from " + $PoolID) -foregroundcolor "Red"

This script should run on View server directly.


Davoud Teimouri

Professional blogger, vExpert 2015/2016/2017/2018/2019/2020/2021/2022/2023, vExpert NSX, vExpert PRO, vExpert Security, vExpert EUC, VCA, MCITP. This blog is started with simple posts and now, it has large following readers.

Leave a Reply

Your email address will not be published. Required fields are marked *