Find duplicate VM UUID’s

As I created a script to gather all VM-s and their UUID, the purpose was to find all the duplicate UUID’s if there where any.
While my script was running I remembered something to find out the duplicates.
Before I forget I tought to put it here so it’s easily to find again

import-csv file.csv | Group-Object -Property UUID -noelement | ?{$_.Count -gt 1}?{$_.Count -gt 1}

Install HP bundles ESX command line

Download the correct bundles from the HP site, I used our UDA as webserver where I uploaded the bundles too. It’s also possible to deploy them using the update manager. To install the HP bundles it’s needed to put the ESX host in maintenance mode. Below I posted some commmands to do this.

#Enter Maint. Mode
vicfg-hostops --server ESXHOST --username ROOT --password ROOT_PASS --operation enter
#Install HP Bundles
vihostupdate --server ESXHOST --username ROOT --password ROOT_PASS -install -bundle
vihostupdate --server ESXHOST --username ROOT --password ROOT_PASS -install -bundle
#Reboot host
vicfg-hostops --server ESXHOST --username ROOT --password ROOT_PASS --operation reboot

#Exit maint
vicfg-hostops --server ESXHOST --username ROOT --password ROOT_PASS --operation exit

VMA add SNMP targets, enable and test on ESXhosts 4.1

First login to your VMa!

To add a SNMP target to your ESX host you can use the following command:
ESXhost: Fill in your ESX hostname or IP
ROOT: fill in the root user, or user with enough permissions to set the SNMP traps
ROOT_PASS: password of the user
snmptarget1: the first snmp target you want to send the SNMP traps too
162: port number to traps
community: the community

I divided the commands in two parts, so the first command line sets the targets on the ESX hosts and the 2nd command line enables and sends a test trap.
You can put the -E and -T option behind the first line, but I noticed it isn’t always working flawless.

#Add SNMP target
vicfg-snmp --server <b>ESXHOST </b>--username <b>ROOT </b>--password <b>ROOT_PASS</b> -t <b>snmptarget1</b>@<b>162</b>/<b>community</b>,<b>snmptarget2</b>@<b>162</b>/<b>community</b> -c <b>community</b>
vicfg-snmp --server <b>ESXHOST </b>--username <b>ROOT </b>--password <b>ROOT_PASS </b>-E -T
#Show SNMP settings
vicfg-snmp --server <b>ESXHOST </b>--username <b>ROOT </b>--password <b>ROOT_PASS </b>--show

To set the traps and enable this it’s not needed to put  a host in maintenance mode.
Aferwards, check on your target if the SNMP traps are received. Make sure that your SNMP target is reachable from the ESX hosts.

Because I didn’t want to do this for each server I made a little .SH script which sets this for all servers found in VIFP LISTSERVERS

See example:

vifp listservers|while read a b c; do /usr/bin/vicfg-snmp --server $a -username <b>root </b>--password <b>ROOT_PASS </b>-t snmptarget@162/patrol
vifp listservers|while read a b c;do /usr/bin/vicfg-snmp --server $a -username <b>root </b>--password <b>ROOT_PASS </b> -E -T;done

So now it’s only needed to start  the script to set the SNMP traps on all your servers. It’s also possible trough powerCLI but I tought this was easier.

Also added the SNMP trap settings to our kickstart script. So I’m always sure the SNMP traps are set as soon as a (new) server is installed.

Remove remote directory using RD command.

I recently found out that the old MS-DOS command RD (Remove Dir) is also working on remote machines.
Just the easy command RD /s “computerC$temp” does the trick.Now if you need to delete the same directory on a whole bunch of machines make a little for loop and cross fingers you have the correct directory.Little example including a ping:

FOR /F %%s IN (server.txt) DO (set Srvr=%%s&Call:ping)
ping -n 1 %Srvr%| find "TTL"
if errorlevel 1 goto Noresponse
rd /s /q %Srvr%c$tempinstall
goto error

echo %Srvr% Unreachable
echo %Srvr% Unreachable >>error.log
goto done

if %ErrorLevel%==0 goto label0
goto done

echo %Srvr% %ErrorLevel% Success The operation completed succesfully>>error.log
goto done


Performace Analysis of Logs (PAL)

With my previous post about PolyMonRT I also would like to share PAL with you.

PAL is a  performance analyzer which analyzes your perfmon tracing with the Best Practice Treshholds from Microsoft for most of their products.

With the help of a easy GUI you can simply select your performance log and start the analyzing.
When the analyzing finished it’s reported in a nice colored HTML view which shows your warning and critical points you could review to let your machine perform better 🙂

Required Products (free and public):
– PowerShell v2.0 or greater.
– Microsoft .NET Framework 3.5 Service Pack 1
– Microsoft Chart Controls for Microsoft .NET Framework 3.5



I have been working on some perfmon counter knowledge and came across something I would like to share. If you know what kind of things to measure you can visualize this with PolyMonRT or PolyMon. Yes there are some other products available which look better, but this one is free.

It’s highly customizable so you can get out whatever you want.


Nslookup range of IP adressess

I was searching for all machines in a certain IP address range to see which machines are in this range and what their host address is.

While trying to create a good working script for the purpose I needed, I came accross the following line which had like all I needed without using nslookup.

0..255 | % { [System.Net.Dns]::GetHostByAddress("192.168.1.$_") } 2> Out-Null

The range is for this script is  -> with the 2>out-null only valid returns are replied in a nice list.

Manage Remote Desktop Sessions from CMD

I used to receive the maximum number of connections error message when I try to log on to the Windows 2003 Server in my office via Windows Remote Desktop.

This is pretty annoying if you have some urgent work to do in the server. Most of the already logged in users won’t even be using the session at the time, but I can’t login! So how to solve this? After a bit of googling, as usual, I found a simple way to disconnect other remotely logged in sessions. :D

First of all you must be logged in to your client computer as a domain Admin user. Now open the command prompt and type in the following command.

qwinsta /server:SERVERIP

The Ip address or domain name of the Remote server should be entered in place of SERVERIP

qwinsta /server:

You will get a list of the Remote Sessions in the command window.

In the above sceenshot we can clearly see an Active RDP session with the ID 2 which belongs to the user Administrator. In order to disconnect that user we are going to use the session ID. Use the following command line to disconnect the remote session.

rwinsta /server:SERVERIP SESSIONID

For example in order to terminate the session of the Administrator user the following command should be given.

rwinsta /server: 2

Now let’s confirm if the user is really disconnected. Just type in the qwinsta command in proper format.

As you can see our session with ID 2 is no longer there. Now for the user we just disconnected will see the following message.

The remote session was disconnected because you session was logged off at the remote computer. Your administrator or another user might have ended your connection.

Source : TechTalkz

1 5 6 7 8