Friday, October 17, 2008

List vm usage and assosiated datastore

Hi all,
 
in a fairly large environment the tracking of a VM's Disk usage and the datastore on who i resides i a trivial task.
 
$datastoreExp = @{N="Datastore"; E={ ($_ | get-datastore | select-object -first 1).Name }}
$diskSizeExp = @{N="Total Disk"; E={ ($_ | get-harddisk | measure-object -property CapacityKB -sum).Sum }}
get-vm | select Name, $datastoreExp, $diskSizeExp | sort -property Datastore,"Total Disk"
 This small PowerShell script pulls a list of all VMs and the disk ussage pr. vm and on witch datastore it is connected to/placed. Be aware if an iso is mounted from a datastore this will generate an aditional entry for the VM in question.

Thursday, September 18, 2008

Updating tools on VM's in Vmware

Hi
 
I'm back, after a long break, with other important stuff on the horizon. I realize i have a couple of hundred vm's that needed the tools to be update and i didn't want to do it manually one by one. So i again looked into the VI-toolkit for Vmware and found it pretty easy to update all vm's with a simple script.
 
$VmList = Get-VM | Where-Object {$_.Powerstate -eq "PoweredON"} | % { Get-View $_.ID } | where {$_.guest.toolsstatus -notmatch "Ok"} | Select Name
foreach ($vm in $VmList) {
  "Updating :" $vm
  Update-Tools $vm
}
 
I hope this can help others.

Monday, July 28, 2008

Disable and Turn Off IPv6 Support in Vista

IPv6 (Internet Protocol version 6) is the successor for IPv4, the current version of most popular network layer protocol for packet-switched internetworks used on the Internet. In Windows Vista, IPv6 is fully implemented and supported, is also installed and enabled by default, with full Internet Protocol security (IPsec) support for IPv6 traffic and Teredo tunneling support for non-IPv6 aware devices.

IPv6 is not common yet, as most software, routers, modems, and other network equipments does not support the emerging and future-proof protocol yet. Beside, turning off IPv6 support does not affect the functionality of Internet browsing for average users. Thus IPv6 and/or Teredo can and (quite likely) should be disabled if it's not in use to conserve system resources. Unlike Windows XP, IPv6 in Windows Vista cannot be uninstalled, according to Microsoft. However, IPv6 can be disabled. The following guide will allow users to disable IPv6 on a specific connection of a network interface card.

  1. Go to Network Connections folder (click on Start button, then right click on Network, select Properties, then click on "Manager network connections" on Tasks pane).
  2. You should see various LAN, wireless, Bluetooth, high speed Internet, and other network connections available on the Vista computer with the network adapter description. Right click on the network connection that you want to disable the IPv6 interface and select "Properties".

    Click "Continue" on User Access Control permission request prompt.

  3. Clear the check box next to the Internet Protocol version 6 (TCP/IPv6) component in the list under "This connection uses the following items" box.

  4. Click OK when done.
  5. To re-enable IPv6, tick back the check box.

This method disables IPv6 on the particular LAN interface and connection. For other network adapter or connection, users have to repeat the steps to disable IPv6. Beside, disable IPv6 also does not disable IPv6 on tunnel interfaces or the IPv6 loopback interface.

It's also possible to disable IPv6 and/or Teredo via Vista system registry. The registry settings also allow users to selectively disable components and configure behaviors for IPv6 in Windows Vista.

  1. Open Registry Editor (regedit).
  2. Navigate to the following registry key branch:

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\
    Services\tcpip6\Parameters\

  3. Create the following registry value (DWORD type):

    DisabledComponents

    Note that the name must be exactly as shown, including capitalization. DisabledComponents is set to 0 by default.

  4. The DisabledComponents registry value is a bit mask that controls the following series of flags, starting with the low order bit (Bit 0). To determine the value of DisabledComponents for a specific set of bits, the process is complicated, were hexadecimal value is calculated from binary number of the bits in correct position. For convenient, the following table lists some common configuration combinations and the corresponding DWORD value of DisabledComponents.
    Configuration combinationDisabledComponents value
    Disable all tunnel interfaces0×1
    Disable 6to40×2
    Disable ISATAP0×4
    Disable Teredo0×8
    Disable Teredo and 6to40xA
    Disable all LAN and PPP interfaces0×10
    Disable all LAN, PPP, and tunnel interfaces0×11
    Prefer IPv4 over IPv60×20
    Disable IPv6 over all interfaces and prefer IPv4 to IPv60xFF

    As seen from table above, to disable IPv6 support globally on all interface, set the value data for DisabledComponents to 000000FF, or simply FF. The registry entry will look like below:


    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters]
    "DisabledComponents"=dword:000000ff

  5. Restart the computer for changes to take effect.
  6. To revert and enable IPv6, delete "DisabledComponents" registry key or set its registry value to 0.

Tuesday, July 22, 2008

Sending mail from Esx 3.x servers

So now i'm back from holiday and was wondering what has happened in my production ESX environment. Well thats not so easy to find out unless you have set up some logging and reporting.
 
To do that easy you need to be able to send emails from the ESX servers. By default that is disabled. But it is very easy to overcome. download the MIME-Lite-3-0-1 module from http://search.cpan.org/~yves/MIME-Lite-3.01/lib/MIME/Lite.pm install it by:
 
tar zxfv MIME-Lite-3.01.tar.gz
cd MIME-Lite-3.01
perl Makefile.PL
make test
make install
 
Then you should be ready to send mails by using the smtp_send.pl script from http://www.jeremypries.com/wp-content/plugins/wp-downloadMonitor/download.php?id=5
 
Then it should just be creating the reports you want in the various cron libraries.
 
Btw the esx-diag tool from Veem tells a great deal on the configuration status of your ESX servers.

Saturday, June 21, 2008

ESX LUN Load balance

After having fighting my way through the Virtual Client setting the active and preferred path for all my currently 22 Lun's on my 24 ESX servers to load balance the load over as many HBA's as possible i looked at the script i could find on the net and saw that the scripts all set the paths to the same for all hosts.
 
I was looking at different scripts out there and found the one below. I need an idea on how to randomize some of this because otherwise it will always be the same om all hosts and if there are 4 hba' as in my case the fourth one will newer be used. I need to set the counter to some random number between 1 and the PATHS value for the hba assignment to start somwhere..   :
#! /bin/bash
#
# by Allan Christiansen/2008 on esx 3.5.0 Update 1
#
for PATHS in 2 4 6 8 10 12 14 16
do
   STPATHS=${PATHS}
   COUNTER=${RANDOM}
   while [[ ${COUNTER} -gt ${PATHS} ]];
   do
      COUNT=`expr ${COUNTER} / ${PATHS}`
      COUNTER=${COUNT}
   done
   for LUN in $(esxcfg-mpath -l | grep "Disk" | grep "has ${STPATHS} paths" | awk '{print $2}')
   do
      esxcfg-mpath --lun=${LUN} --path=$(esxcfg-mpath -q --lun=${LUN} | grep FC | awk '{print $4}' | awk '{print NR "S\t " $0}' | grep ${COUNTER}S | awk '{print $2}') --preferred
      COUNT=`expr ${COUNTER} + 1`
      COUNTER=${COUNT}
      if [[ ${COUNTER} -gt ${STPATHS} ]]
      then
         COUNTER="1"
      fi
   done
done
 
 

Thursday, June 19, 2008

Windows Vista Power Button

After a couple of month with Windows Vista i found that the default behavior of the start menu Power button anoyed me alot, especialy on my Desktop pc. I was researching and playing around and found how to change what the start buttons do.. You can change how the shutdown/sleep buttons function in local group policies (gpedit.msc) COMPUTER CONFIGURATION > ADMINISTRATIVE TEMPLATES > SYSTEM > POWER MANAGEMENT > BUTTON SETTINGS

Changing these values will resolve this idiotic default idea that MS came up with of pressing the power button and it going to sleep....

Another way is in the advanced power settings.


I hope that this can help you out a bit.

Tuesday, June 17, 2008

Vmware ESX

I have for some time been using vmware ESX and found that the software from them is perfect for the growing IT environment that exists in a majority of companies. But i also discovered that managing an environment that is growing fast needs a lot of care and strict procedures. e.g. with vmware there is a possibility to move a vm from one host to another host without user interruption. This is sadly only possible if the cdrom drives are not locked to a iso or otherwise occupied.

I found that running this small powershell script helps alot on that.

Get-VM Get-CDDrive ? { $_.ConnectionState.Connected -eq "true" } Set-CDDrive -Connected:$false -Confirm:$false

This also is a great small script to have in mind when evacuating an ESX. there's nothing more annoying than the last vm will not evacuate because of a mounted cdrom drive or a not ended tools install.

BTW. Thanks alot to Microsoft for the powershell. And for vmware for implementing it in such a great fashion.

Thursday, June 5, 2008

Just another IT Blog? or

Is this just another IT blog?

Yes and no. Yes its a IT blog. and no this is one where i will share the small scripts, gadgets and sniplets i create or piece together from my daily work and travels around the net.

So who am I:

Name : Allan Christiansen
Age : 37 at the moment (Born 1970)

Experience : 20 years of Professional IT. Mostly with Microsoft products but i have also worked some time with Linux. Lately I have worked alot with vmware.

Exams : MCSE 2003 : Messaging / MCSE 2003 : Security / MCTS SQL 2005 / MCP

Hope to see you all around and please have fun while working. It makes it easier to relax.