Tuesday, February 15, 2011

Get / Determine / Check your ESX version, major version or build version

To check your esx version, use in command line:


vmware -v
return for example in a 3.0.1 ESX
VMware ESX Server 3.0.1 build-32039

vmware -v
return for example in a 3.5 ESX
VMware ESX Server 3.5.0 build-238493

vmware -v
return for example in a 4.1 ESX
VMware ESX 4.1.0 build-260247



But If you need to know only version use

vmware -v | awk -F "uild" '{print $1}' | sed -e 's/[A-Za-z ]//g'

return in our 3 examples
3.0.1
3.5.0
4.1.0


In your script you can use this information into a variable

ESX_VERSION=`vmware -v | awk -F "uild" '{print $1}' | sed -e 's/[A-Za-z ]//g'`
echo $ESX_VERSION

return in our 3 examples
3.0.1
3.5.0
4.1.0




To know major version only

vmware -v | awk -F "uild" '{print $1}' | sed -e 's/[A-Za-z ]//g' | cut '-d.' -f1

return in our 3 examples
3
3
4


To know major and minor version only

vmware -v | awk -F "uild" '{print $1}' | sed -e 's/[A-Za-z ]//g' | awk -F "." '{print $1"."$2}'

return in our 3 examples
3.0
3.5
4.1


If you need to know build only

vmware -v | awk -F "uild-" '{print $2}'

return in our 3 examples
32039
238493
260247

No comments: