Gerben’s Blog on Virtualization

Virtualization is becoming a standard

Powershell script to query VMware ESX Servers

Posted by Gerben on 08/11/2007

Hal from (TechProsaic) wrote a PowerShell script to query ESX hosts.

I saw an entry on NTPRO.NL about the script and because I recently attended a session about PowerShell I was triggered to give it a try and test it for myself.

The script makes use of PLINK.exe from the PuTTY project. I already had the app in my environment variables loaded. I tried to figure out how to use the object because at that time there was a credential problem at which resulted in the BLOG being not available. The download link to the script on NTPRO.NL was available though, so I decided to give it a try without extra documentation.

At first I had some problems with the syntax of the script (use quotation marks around the ESX hosts helped). Later on I was sure I was using the right syntax but the script still did not work, it kept returning an error about a value being null. Looking closer I found that the password for the ESX host caused the troubles. The password contained a special character "&", which was misinterpretered by Powershell  and this resulted in a wrong password being piped to PLINK.EXE.

Excluding the Host in question from the query solved the issue and the script delivered a nice output with the vm’s registered at the remaining hosts.


2 Responses to “Powershell script to query VMware ESX Servers”

  1. (no name) said

    I can’t believe that I forgot to add the URL. The URL is


  2. (no name) said

    Hi. I saw your blog posting about using Powershell to query ESX hosts. I’m just starting a blog on scripting in general but I will be focusing on ESX and Powershell scripts. One of my first posts involves listing VM snapshots using Powershell and how it differs from the Perl SDK from Vmware. I would love to hear your thoughts on the post.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: