Unofficial PowerShell SDK for VMware View (part 1)
Welcome to this first part of the ‘unofficial SDK for VMware View”. You might wonder, why “unofficial”? Well, simple, VMware View is one of the few products from VMware that does not have an SDK
So if you want to script/program/automate anything against VMware View, you are out of luck. That is, officially you can not.
VMware View uses Microsoft ADAM (Active Directory Application Mode) to store its data. After a day of googling and puzzling, I was finally able to figure out how to do some of these ADAM calls myself using visual basic and powershell. In this part 1, I want to share 2 beginning powershell scripts with you.
Script 1 – Show Desktop Pool Properties
$poolname = "type_here_your_pool_Unique ID name"
$connectionbroker = "type_here_your_IP_of_your_connection_broker"
$userName = "type_your_username"
$userPassword = "type_your_password""
$ldaproot = "LDAP://$connectionbroker/CN=$poolname,OU=Applications,DC=vdi,DC=vmware,DC=int"
$directoryEntry = New-Object System.DirectoryServices.DirectoryEntry($ldapRoot)
$directoryEntry.psbase.Username=$userDn
$directoryEntry.psbase.Password=$userPassword
$directoryEntry.get_Properties()
Script2 – Disable/Enable a desktop pool
$poolname = "type_here_your_pool_Unique ID name"
$connectionbroker = "type_here_your_IP_of_your_connection_broker"
$userName = "type_your_username"
$userPassword = "type_your_password"
$ldaproot = "LDAP://$connectionbroker/CN=$poolname,OU=Applications,DC=vdi,DC=vmware,DC=int"
$directoryEntry = New-Object System.DirectoryServices.DirectoryEntry($ldapRoot)
$directoryEntry.psbase.Username=$userName
$directoryEntry.psbase.Password=$userPassword
# 0 = enabled 1 = disabled
$directoryEntry.InvokeSet("pae-Disabled",0)
$directoryEntry.CommitChanges()
Script 2 can be used to make any changes. If you for instance did not want to change the pool state, but it’s displayname, you can just replace the 2nd last line with:
$directoryEntry.InvokeSet("pae-displayname","type_your_new_display_name")
The next thing I want to find out is how to query which desktops are actively being used and the state of each desktop, but I have not been able to figure this our yet. If anyone would like to help out on this project, please contact me!
| Print article | This entry was posted by Richard Garsthagen on April 18, 2010 at 8:51 pm, and is filed under Programming and Scripting, VDI. Follow any responses to this post through RSS 2.0. You can skip to the end and leave a response. Pinging is currently not allowed. |


about 3 years ago
Hi Richard,
as always very well done article!
about the query of which desktop being used and its state, I’ve done some research as well but, hoping to be wrong, I’ve discovered that are “transient” information… actually noway stored just in Memory, so you have to look trough the logfiles, as you teach me in the vAudit
Maybe in next releases we will be more happy to have a respectful SDK for View…
Cheers,
Andrea.
about 3 years ago
Richard, cool stuff.
At VMworld 2009 VMware announced that View 4.5 (I think that’s the version anyway) will have an official PowerShell snapin, so shouldn’t be too much longer. Hopefully that will make a lot of this stuff easier, but knowing how to automate ADAM is still very handy.
about 3 years ago
Hey Richard.. awesome..
How about displaying when your users are logging in to their virtual machines duration of use and unsuccessful login attempts..
Intrigued to see when vmware have an official PoSH snapin..
Cheers..
Jagz
about 3 years ago
Good info. Like Jagz, I am interested in getting more user info. Is there any way to query that? I’m looking for things like: for a running VDI VM, what user is logged into it; generate an alert when a user logs in (to tie into my virtual firewall).
about 2 years ago
Any thoughts on add how to use this technique to add and delete users/group to desktop pools?