Programming and Scripting

Programming and Scripting information

VMworld 2017 (EU) – Hackathon

So it has been a while πŸ™‚ and my great employer is allowing me to visit VMworld Europe. I saw there was a hackathon, so a great opportunity to bring back an quite old project of mine that I never really finished. physical monitoring tools for your VMware/Cloud environment.

So what will we do? might wonder. Well we mainly will be using Raspberry PIs to control physical devices, both analog and digital, based on information from your VMware environment. We can also add some switches and buttons, so we can make it a 2-way street.

But… we need your help! If you are attending VMworld in Barcelona, come join our team (#8). It is great if you have programming skills, but that is not mandatory! If you have great ideas about what metrics, log files, etc we should poll so we can actually show useful information, that will be super useful as well. If you have AWS api knowledge also super awesome!

You can find more information about the event below. There is a link to a google Document where you enter your name to our team.

Updated VMware Scanner in Python3

Over the years I have been getting frequent request to the source code of the VMware scanner. So I decided to re-write it for python (version 3) and make it available. It actually handles the multi tasking better and is faster scanning.

It still shocks me how many VMware servers are directly connected to the internet, including some seriously old versions.


You can download the python script here

Here the script on github:

New vSphere5 php sample code released

It was a while back I wrote a PHP manual for programming against VMware Virtual Infrastructure 3 (VI3). Assuming most of you run now-a-days vSphere 5.x I finally got around updating the samples πŸ™‚

I am using this code myself for myΒ Raspberry PI analog monitor box for vSphere

You can find my basic explanation in the vSphere 5 PHP guideΒ and the sample files in the download section





VMware goes PHP :-) yeah!

PHP, my favorite programming language was never really polulair within VMware, but as more and more solutions are focused on cloud computing, VMware needs to address the needs of service providers who ofter do have a lot of code based on PHP.

To endeavor in this PHP world, VMware’s just release the first public beta of the VMware vCloud SDK for PHP. This SDK allows you to interface to VMware vCloud Director.

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)


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)

# 0 = enabled 1 = disabled

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:


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!

VMware is really showing of they are eating their own dog food

All the selfpaced labs this year at VMworld are automatically being provisioned on-demand by a custom build solution based on Lab Manager. Using the open API for labmanager they have build a Cloud like environment for all the attendees. The system does not just provision ‘normal’ virtual machines like windows, but entire virtualized ESX environments, so running ESX inside ESX, with SRM and VC server.


Yes, I agree with mr Steve Ballmer, developers are important and not just to Microsoft, but also to VMware. That is why VMware is organizing the Technology Exchange Developer Day, one day before VMworld starts on August 31st in San Francisco.

More and more people are developing in-house special programs to manage/monitor their Virtual Environments, if you are one of them, this would be your event to go to! There will be sessions about the vSphere API, VDDK API, VIX API and much more.

I personally will be going as well and happy to talk to anyone about the APIs and how to program using them. If you want to know all sessions, you can check out the schedule here

The VMware Technology Exchange Developer Day

Scriptkiddies: Win a Free trip to VMworld Las Vegas or $5000

Want to go to VMworld Las Vegas for free? or just a nice $5000 cash price? Well start writing some cool Powershell scripts that do awesome things against your VMware Infrastructure πŸ™‚

VMware’s Powershell extension for VI3 is really great. It combines the power and ease of PowerShell with the long list of API for VI3. So get creative and make some cool script that you can show off to the entire virtualization community!

To help you get started:
Download the VMware Powershell toolkit
VMworld Europe Power Shell presentation
The VMware Powershell blog
The VMware Powershell Forum

The contest if open until august 30th! To enroll into the competition go to:

Get full control over your ESXi Server

As you probably know ESX 3i is the embedded version of ESX, mainly run from usb flash disks build-in servers from HP, Dell, IBM and FSC, but you can also install this on your own servers. I really love this version as it is so easy and simple and adds extra (and less) functionality to ESX. The main thing about 3i is that the Red Hat service console has been removed and replaced by a small busybox linux version. To keep this service console tiny, 3i comes with build-in hardware monitoring, something a normal ESX server does not have (wish it did). When connecting to a 3i server with your VC client you can see fan speeds and temperatures in your system and you can of course put alarms on them, in case something breaks.

By default the 3i server gives us no access to this small service console, but there are some down sides to this, as certain things can only be done from the service console πŸ™ and until VMware builds those missing functionalities into the VC interface you still need to get yourself console access. In the beta versions of 3i there was an option in the advanced settings, but this has been removed in the final releases. VMware has published a knowledge base article that describes how to get console access (this is not officially supported by VMware). See the KB Article. In short you just hit Alt-F1 and then type in ‘unsupported’. The article also explain how to disable this Tech Support Mode, in case you want to.

Getting console access

Of course you do not want to be in the server room all the time and your server might not have some kind of remote access facility, so the first thing you probably want to do is enable SSH access to your server. (Thanks to Lee for this information, and again this is not supported by VMware)

  • edit /etc/inetd.conf (using vi)
  • remove the # (remark) sign in front of the SSH line
  • kill and restart the inetd process (or just reboot your server)
  • So why do you need console access?
    There are multiple reasons why you want to have console access. One of the most common reasons is that you might want to change HBA driver options. To get better performance out of your Qlogic or Emulex HBA most people increase their queue depth (see for instance VMware 100.00 io blog post). To find out what options you can set on your drivers you can use the command vmkload_mod:

  • display your loaded drivers: vmkload_mod --list
  • display parameters for your driver: vmkload_mod -s /mod/your_driver
  • Another reason why you definitely still need console access (unfortunately) is if you want to use thin provisioned virtual disks, a new feature in ESX, but for some reason not exposed in the VC interface yet (i think because it is still experimental supported). Any virtual disks created via the normal interface are pre-allocated disks, so a 100GB virtual disk will use 100GB on your VMFS. With thin provisioned disks the actual virtual disk file will start very small and only grow when you will actually need the disk space. Note: this only works for Virtual Disks on iSCSI and FC SAN, not NFS!

    With the vmkfstools command you can create new virtual disks as ‘thin’ disks. After you created the disks, you can then use the normal VC interface to add that disk to your VM.

    Creating a 100GB thin disk:
    vmkfstools -c 100G -d thin /vmfs/volumes/san_vmfs/my_vm/thin_disk.vmdk

    If you already have a pre-allocated disk, you can convert it to a thin disk as well. Well it is not really converting, but creating a new copy as thin disk. After you have done that, you will need to remove the old disk from the VM and add the new converted copy.

    ‘convert’ copy a existing virtual disk to thin format:
    vmkfstools -i /vmfs/volumes/san_vmfs/my_vm/large_disk.vmdk -d thin /vmfs/volumes/san_vmfs/my_vm/new_thin_disk.vmdk

    Well I am sure there are more reasons why you still want to ‘play’ on the service console, as I am born with a commodore 64, I always want a command prompt πŸ™‚

    VMware releases new Virtual Disk Development Kit 1.0

    VMware has released this week a new toolkit for virtual disk management that is looking very promising.

    The VDDK provides easy access to virtual disk storage. This enables a wide range of solutions including:

  • Creation of virtual machine disk files to store backup of physical images.
  • Read access to virtual disk to enable off-line centralized scanning of virtual machines for anti-virus.
  • Write access to virtual disk to enable off-line centralized patching of virtual machines.
  • Read access to virtual disk to enable off-line software package analysis of virtual machines.
  • The new API supports managing two kinds of disks; Managed Disks (local virtual diskfiles) and Hosted Disk (virtual disk files on you ESX/VMFS systems). This means the API will allow you to access disks remotely and opens a low of new opportunities for companies making virus scanning software, backup, forensic, etc.

    More on the new API:
    The Virtual Disk API Programming guide
    The Virtual Disk Development Kit Homepage