Control VMware ESXI (free hypervisor) with Powershell and SSH

Powershell, VMware

Some time ago i wanted to to run some build scripts in my home lab which needed to power off and on a virtual machine running Independent Non-Persistent disks in order for the VM to be in a clean state before each build. However i was running the free hypervisor version of ESXI so the api was not available, then i figured that i could do this via SSH and Powershell. In order for the example script below to work you will need to do a couple of things to the esxi server and the machine executing the script.


You will first need to make sure you have the powershell ssh module copied to the following locations on the machine executing the script:



You can download the file from here: SSH-Sessions

*Note i am not the creator of the SSH-Module and the original is located at


Then you will need to generate a public/private key for the SSH user you are going to use and load the public key into ESXI. VMware has made a nice set of instruction on how to do it here.
Keep the private key as you will need it when running the script. You will also need to enable SSH and allow it thru the firewall on the ESXI server.


The below script is an example of what you can do with powershell and ssh on an ESXI server. The script will look for a vm on a specific ESXI server you have specified, it will then check if it’s powered on, if so it will power it off, then it will power it on and wait for VMware tools to be up before finishing:


Virtual machine as nfs (ISO) server for host esxi server



This is an old post i made on the VMware communities earlier this year, i am re-posting it as i don’t want it to get buried, given the amount of post they get in a day :D.

So I decided to post an observation i made during a non standard ESXI setup (couldn’t find anything about it so i am making a post).

This is not a fault or a question more of a discussion.

The circumstance below are due to the limitation of having only one server in a remote site.

What i noticed and i am pretty sure this is not supported or recommended, is that when you have a virtual machine on an esxi host that presents (as a datastore) a NFS full of ISO to VMWare (the esxi host) the machine hosting the NFS cannot use the ISO.

What i mean by the above is if you try and mount an ISO from the NFS datastore on the virtual machine hosting them it will lock up. Now if you try and mount it on any other Virtual machine it’s fine no problem.

The bellow diagram show our setup.

I assume it has something to do with the reconfiguration of the virtual machine when you mount the ISO, maybe a microsecond downtime for it to mount and due to this downtime the ISO presented becomes unavailable and in turn locks up the mount, it’s worth noting when i say it locks up the entire virtual machine locks up. Eventually vmware does pop up a message and ask if i should cancel the mount as it noticed that it’s causing problems. Maybe someone with better understating than me can explain why this behavior occurs.


Now i know there are other ways of doing this like putting the images directly on the datastore but our situation requires that ISO s are synced on regular bases so we use DFS to sync from main site and NFS(usually located on different server) to present to ESXI servers.


VMware virtual nfs to same esxi