Add / Remove port groups and VLANs using the ESXi command line

Useful commands for modifying port groups and VLAN settings on ESXi. Can be used in scripts of course to do additions / removals / changes in bulk.

List vSwitches:
=============================================

List port groups
=============================================

Add port group named “VLAN-900” to vSwitch0
=============================================

Assign VLAN 900 to port group “VLAN-900”
=============================================

Delete port group TEST from vSwitch0
=============================================

Restore XenServer VM snapshots from the CLI / command line

Taking a snapshot from the command line is trivial. Restoring the snapshot is not. From the XenCenter GUI application it’s easy of course, but sometimes you need to automate things. In this case I have an environment for testing which needs to be reverted to the same state after each test.

Each VM has only a single snapshot. Matching the snapshot UUID with the UUID of the virtual machine isn’t easy, but can be done by extracting the parameter called “children” from the snapshot.

To list the snapshots with their respective VM UUID’s, I use the following (i and j variables for snapshot UUID and VM UUID respectively):

To restore the snapshots:

NOTE: This works if there’s only ONE snapshot per VM and you want to restore them all. Otherwise more complex scripting is required to filter out the ones you need. It’s more than enough for our test systems though.

Some basic XenServer VM management from the CLI / command line

List some VMs we care about:
================================================

Take snapshot of the VMs
================================================

Start the VMs
================================================

Stop the VMs
================================================

Shutdown – Take snapshot – Start sequence:
================================================
On one line:

For use in a short shell script (prettier formatting):

Import VMs from directory:
================================================

Export VMs to current directory:
================================================

Error when installing the vSphere6.0 appliance: The file D:\vcsa-setup.html is not in a folder shared with the host and cannot be opened by the host.

When trying to launch the vSphere6.0 appliance installer I just got the following “The file D:\vcsa-setup.html is not in a folder shared with the host and cannot be opened by the host.”

vcsa-setup.html error

After having tried and received the same error after copying the ISO locally, emptying the contents into a folder, mounting it via vCenter5.5 to my VM, etc I simply dragged and dropped the file onto Firefox. That was it – it works.

Funny how these simple things can end up wasting time …