VMware: A (incomplete) list with some PowerCLI Scripts for vSphere


for VMware vSphere a very powerfull Scripting engine is available which is called PowerCLI. PowerCLI based on, the also very powerfull, Microsoft powershell.

The Basics

Get the PowerCLI package from the VMware website and install it on your Windows Computer or on the VMware vCenter Server. Ok, lets start.

Open  PowerCLI Command prompt by clicking “VMware vSphere PowerCLI (32-Bit)” Icon. Note: The 64Bit Version(both the 32Bit and 64Bit versions were installed) did support all commands. For example when you clone a computer by the New-VM Command-Let and specifiy the OSCustomizationSpec parameter the follwing error was thrown.

New-VM -VM "ComputerTemplate" -Location "Windows Clients" -ResourcePool Resources -OSCustomizationSpec "Windows XP Client"  -Datastore esxdatastore0 -Name "COMPUTER1"
New-VM : 26.06.2013 23:37:42    New-VM         is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)

However start the 32Bit Version :-). First you have to connect to your vCenter. If your Windows Account, with which you logged on, have the appropriate rights to connect to vCenter simply call

Connect-VIServer NameOfYourvCenter.domain.com

If logon successeds 2 global object variables are set to which all following commands refers to.

global:DefaultVIServer         NameOfYourvCenter.domain.com
global:DefaultVIServers        {NameOfYourvCenter.domain.com}

Alternatively you can assign the vCenter Object to a variable and append the -Server <VIServer[]> parameter to each command. This is usefull if you have multiple instances of vCenter.

$oSecondVCenter=Connect-VIServer NameOfYourvCenter.domain.com
Set-Vm -VM "OldName" -name "New-Name" -Server $oSecondVCenter

By default, all command are executed synchronous. This means the command prompt returned not until the tasks is finished. To start jobs asynchronus append the -RunAsync parameter to each command line.

Lets start with some example scripts
More »

Windows: Network interface order


some Licensemanager uses the first MAC Address found in system as the HostID. You can use the getmac.exe command to show the list with all NICs.


Physical addresse   Transport Name
=================== ===================================================
5C-9A-D8-AE-DC-0D   \device\TCPIP_{c6a12685-4aed-49a8-b26b-dce59b81b911}
00-DE-94-17-CA-0F   \device\TCPIP_{9f963344-edae-4a42-a992-bb9bc05672bb}
00-CA-BE-17-CA-0F   \device\TCPIP_{ad634d51-ccee-43d5-bef6-ce5749b4cdfd}

In this example 5C-9A-D8-AE-DC-0D was used as the host id. Sometimes, after installing a additional LAN adapter or by removing one, these alignment is disordered and the licensemanager won’t start.

These order is indent by the subkeys of


Each Network Interface has its own subkey started by 0000. The lowest Keynumber is the first in the output of getmac. So order your NICs as you want by renaming the keys(4-digit numbers)


VMware ESXi: A (incomplete) list of host commands Part 3


part 3 of my (incomplete) list of the esx cli.

ESXi Advanced Kernel Settings/Parameters

Get all

esxcli system settings advanced list

Set one, i.e. disable the shell respectively ssh warnings

esxcli system settings advanced set -o /UserVars/SuppressShellWarning -i 1

ESXi Kernel modules

List loaded kernel modules

vmkload_mod  -l

Get a list of all enabled kernel modules

esxcfg-module -q
More »

VMware ESXi: A (incomplete) list of host commands Part 2


here is part 2 of my (incomplete) list of ESXi shell commands

Managing virtual machines

First get the VMID of the vm you want to manage, you need this ID in the following commands

vim-cmd vmsvc/getallvms

Vmid  Name File Guest OS  Version  Annotation
36 .......................................

Power On
vim-cmd vmsvc/power.on 36

Power Off (Soft)

vim-cmd vmsvc/power.off 36

Power Off (Hard)

get the world ID of the virtual machine

esxcli vm process list


World ID: 1625788
Process ID: 0
VMX Cartel ID: 1625786
UUID: 56 4d 9e d3 8b ce ab 59-9b 22 ac 87 40 6c 48 c3
Display Name: TestComputer

And kill them

esxcli vm process kill -t [soft,hard,force] -w

esxcli vm process kill -t hard -w

Reboot a virtual machine
More »

VMware ESXi: A (incomplete) list of host commands Part 1


here is a list of some cli’s  to control a VMware ESXi host from the command line. Enable the ESXi shell and login to console or connect with a ssh client remotely.
Restart Management, HA Services
/sbin/services restart

Installing Software. List/Install/Uninstall  VIBs (vSphere Installation bundle)

List vibs

esxcli software vib list

Install a vib

esxcli software vib install -v file:/tmp/[NewVIB].vib

Uninstall a vib (determine the Name of the VIB by the list command)

esxcli software vib remove -n VIBname

Install a patch

esxcli software vib install /tmp/[patchName].zip


firewall state

esxcli network firewall get

Firewall rules
More »

Original Theme by Schiy · Powered by WordPress