VMware

This Question is Answered

2 "helpful" answers available (6 pts)
3 Replies Last post: Mar 20, 2009 6:45 AM by LucD  

Scipt to update ESX local file (esx.conf) on all hosts posted: Mar 20, 2009 2:24 AM

Click to view gboskin's profile Hot Shot 206 posts since
Nov 19, 2008

http://communities.vmware.com/thread/199361

The thread above works well to pull all the esx hosts logs files.

I have a situtaion where i need to update all the ESX.CONF file on about 50 hosts over two clusters...

Click to view LucD's profile Champion 2,431 posts since
Oct 31, 2005
Are you sure you need to edit this file ?
Can't your change be done with one of the esxcfg- commands ?
Click to view LucD's profile Champion 2,431 posts since
Oct 31, 2005
I used again the plink command but this time I used the -m <file> parameter to pass the commands to sudo.

This is the script that I came up with
Note that the script takes all ESX hosts in a specific datacenter but this can easily be changed.
Also note that if DRS is not set to "automatic" you will have to start the vMotions yourself from the VIC.
The temporary file I use to pass the sudo command to the ESX server can be located somewhere else of course.
Get-Datacenter <datacenter-name> | Get-VMHost | %{
# Place host in maintenance mode
  $_ | Set-VMHost -State Maintenance

# Execute the esxcfg-module command
  $User = <ESX-account>
  $Pswd = <ESX-account-password>
  $Computer = $_.Name
  $plink = "D:\UserData\Tools\Putty\plink.exe"
  $cmd1 = 'sudo -u root /usr/sbin/esxcfg-module -s "qlink_down_timeout=30 qlport_down_retry=255 qlogin_retry_count=255 ql2maxqdepth=32" qla2300_707'
  $filename = "temp.txt"
  $cmd1 | Set-Content $filename
  $plinkoptions = " -v -pw $Pswd -m $filename"
  $command = $plink + " " + $plinkoptions + " " + $User + "@" + $computer
  Invoke-Expression -command $command 

# Reboot the server
  $taskMoRef = ($_ | Get-View).ShutdownHost_Task($true)
  $task = Get-View $taskMoRef 
  while ($task.Info.State -eq "running" -or $task.Info.State -eq "queued") {$task = Get-View $taskMoRef}

# Place host in connected mode
  $_ | Set-VMHost -State Connected
}

VMware Developer

SDKs, APIs, Videos, Learn and much more in the Developer community.

Learn More

Developer Sample Code

Increase your developer productivity with VMware API sample code.

Learn More

VMworld Sessions & Labs

Online access to the latest VMworld Sessions & Labs and online services.

Learn more

Purchase PSO Credits Online

Purchase credits to redeem training and consulting services online.

Buy Now

Community Hardware Software

View reported configurations or report your own.

Learn More

VMware vSphere

Come witness the next giant leap in virtualization.

Register Today

Communities