All posts by Michael Albert

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

Hi,

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

TestComputer

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
1625788

Reboot a virtual machine
Continue reading VMware ESXi: A (incomplete) list of host commands Part 2

Advertisment to support michlstechblog.info

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

Hi,

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.
Management
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

Network

firewall state

esxcli network firewall get

Firewall rules
Continue reading VMware ESXi: A (incomplete) list of host commands Part 1

Windows: Set network parameters from command line by using WMIC.exe

Hi,

you can use wmic.exe  to set some network parameters (and much more, its WMI!!) from command line. Syntax is very hard, but it works :-).

For Example. If you want to disable the DNS registration of all enabled Intel e1000 network adapters.

wmic path Win32_NetworkAdapterConfiguration where (IPEnabled="true" and ServiceName="E1G60") call SetDynamicDNSRegistration False,False

The Filter in the braces is the where condition of wmi “select * from NetworkAdapterConfiguration where IPEnabled=’true’ and ServiceName=’E1G60′ ” statement.  Modify this for your needs. By using WMI queries this is much more flexible than netsh command lines.

Michael

OpenVPN: Set a static IP Address for a client

Hi,

sometimes you have to set a static IP Address for some VPN Clients. Because they provide some server services which always must be reached at the same IP Address.

The client configuration do not provide any option to do that, set a static IP Address on the adapter itself is also always being overwritten when the client establish a connection to the OpenVPN server.

Solution: Define a client specific script at the server.

In this example the openvpn server’s OS is linux (tap Interface IP 10.1.134.62), the client runs at Windows (static IP 10.1.134.1).

Define a directory where the client scripts should be stored , e.g. /etc/openvpn/staticclients and create the directory

mkdir /etc/openvpn/staticclients

Add this directory as option to your openvpn configfile at the server:

client-config-dir /etc/openvpn/staticclients

For each client you have to create a file. The filename must match the “common name” attribute that was specified at the X509 certificate of the client.This command gets the CN from the computers certificate:

root@devdeb~ > openssl x509 -in /etc/openvpn/yourClientCertificate.cer -noout -subject | sed -e 's/.*CN=\(.*\)\/.*/\1/'

TESTCLIENT

This example pushs the IP Address 10.1.134.1/255.255.255.192 to the Client with the common name TESTCLIENT and also pushes a additional route for subnet 10.1.135.0.

cat /etc/openvpn/staticclients/TESTCLIENT

ifconfig-push 10.1.134.1 255.255.255.192
push "route 10.1.135.0 255.255.255.0 10.1.134.62"
# push "dhcp-option WINS addr"
# push "dhcp-option DNS addr"

Michael

Reset the print protection of a pdf document

Hi,

last week a customer had the problem that he lost a Word Document which he wants to print. Only a pdf of the document was available but in this file the print protection flag was set.

I used Ghostscript to reset the print protection.

Install Ghostscript and use this command line to write a new version of the pdf file which is printable


gswin.exe -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=d:\temp\OUTPUT.pdf -c .setpdfwrite -f D:\Temp\input.pdf

Michael