Difficulty in clearing inactive VMs from Dedicated VDI Pools? Not Anymore : )
Even though Dedicated VDI pools are rapidly being replaced by Floating pools, we still have few use cases which requires a Dedicated VM. Being a VDI Administrator it's really important to keep a check on these Dedicated pools and cleanup any unused VMs regularly to make sure the resources are being utilized where it's actually needed. It maybe a very time consuming or boring task to find all the VMs which are not being used and delete them to free up the resources. We can delete the VMs based on 2 criteria
Delete VMs for disabled user accounts
Delete VMs which are not used in last "N" number of days
Now, in this article we'll be covering the first point "Delete VMs for disabled user accounts"
We have written a very simple script which does the below list of tasks
Get the list of all Dedicated Pools within the POD.
Get the list of users who are having a VM Assigned/Dedicated to them in these pools.
Check the user account against AD and check if the account is enabled or disabled.
If the user account is disabled, then delete the VM assigned to the user.
Write all the information in a log file.
Note the username, PoolName and VM name for all the Deleted VMs in a CSV file and send it as email attachment to administrators.
Before you execute the script make sure you have imported all the Horizon Helper PowerCli Module from here - Horizon Helper Modules