Wednesday 16 November 2011

How to Find Virtual Center IP from ESX Host


Guys Sometime we forget the VC IP but we know the IP of ESX/ESXi, such situations generally occurs when we are working in large distributed IT infrastructure or if we are working as newly hired for client and do not have adequate knowledge transfer sessions. Even I did this First time and was not aware of this before untill someone asked me to know "how to fetch this info"..





CASE SCENARIO: My VC IP is 192.168.131.20 ( and I do not know about this) and some how I know the ESX IP or name ( ESX IP is 192.168.131.9)




>I chose any one of ESX\ESXi for which I'm looking for VC IP\Name

>log in to ESX\ESXi as root




> type below command:



grep "Manager IP" /var/log/vmware/vpx/vpxa.log



Output :
in above output Manager IP communicating to port 902 using vpxa agent is IP of your VC


~ #
~ # [2011-11-16 13:33:27.094 0x764e2ab0 info 'App'] [VpxaInvtHost] Manager IP: 192.168.131.20:902   Host IP: 192.168.131.9 Preserve IPs: false

~ #
~ #




Wooo !! Looks Good to me now !!!

Tuesday 8 November 2011

Auto upgrade VMware Tools on multiple Virtual Machines on next reboot

This will save huge time and effort of an administrator when he needs to update VMware tools on hundreds of VMs . Here I used PowerShell scripts to achieve the results:



Pre-Requisite :

> Windows Powershell 1.0



> VI Toolkit (login with an account, or registrar it is free)






1>Install VI ToolKit on workstation and PowerShell

2>Start the VI Toolkit

3> Connect to the Virtual Center server with command:

Command Syntax:



connect-viserver -server <VirtualCenter Server IP address> -user <VirtualCenter User> -password <VirtualCenter password>



4>Copy & Paste the following command in Toolkit Window:

 Command Syntax:

Foreach ($v in (get-vm)) {

$vm = $v | Get-View

$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec

$vmConfigSpec.Tools = New-Object VMware.Vim.ToolsConfigInfo

$vmConfigSpec.Tools.ToolsUpgradePolicy = “UpgradeAtPowerCycle”

$vm.ReconfigVM($vmConfigSpec)

}





press ENTER twice to start execution, Check recent task in VC progress will be shown there.



Now when your VM's Boot next time, tools will automatically installed on them.





5> Question:  Now VMTools will start getting installed every time (in future as well) VMs boot or get restarted. How to avoid this.

Ans: Once tools installed we do not wants VM's to give a check or install instructions every time when it boots. so we need to rollback the task that we did above in PowerShell script



6> to Rollback copy below script in VI toolkit windows:

Command Syntax:

Foreach ($v in (get-vm)) {

$vm = $v | Get-View }

$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec

$vmConfigSpec.Tools = New-Object VMware.Vim.ToolsConfigInfo

$vmConfigSpec.Tools.ToolsUpgradePolicy = “Manual”

$vm.ReconfigVM($vmConfigSpec)

}









Voila!! you are done now..





Additional:



1>you may wants to update VMTools on specific VMs. let's say all VMs with name containing "Desktop" then you need to use below script:

 Command Syntax:

Foreach ($v in (get-vm)) {

If ( $v -like “Desktop*”) {

$vm = $v | Get-View

$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec

$vmConfigSpec.Tools = New-Object VMware.Vim.ToolsConfigInfo

$vmConfigSpec.Tools.ToolsUpgradePolicy = “manual”

$vm.ReconfigVM($vmConfigSpec)

}

}



2> Another example, if you want set installation on Tools, on all VMs except VMs with name containing "Desktop" then you need to use below script command:

 Command Syntax:

Foreach ($v in (get-vm)) {

If ( $v -notlike “Desktop*”) {

$vm = $v | Get-View

$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec

$vmConfigSpec.Tools = New-Object VMware.Vim.ToolsConfigInfo

$vmConfigSpec.Tools.ToolsUpgradePolicy = “UpgradeAtPowerCycle”

$vm.ReconfigVM($vmConfigSpec)

}

}