VMware Cloud Community
eabennet
Contributor
Contributor
Jump to solution

Check version of ESXi and only run commands on certain versions.

I know this is probably simple fix but I am coming to a blank.

What I need to do is check the ESXi version to make sure it is above 6.x before running code and running different code on 5.x hosts.  My pseudo code is below.

If (host level = version 6.x)

{

     run code set 1

}

else

{

     run code set 2

}

Thanks in advance.

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You have to use the -eq operator, like this

$esx = Get-VMHost -Name MyEsx*

If ($esx.Version -eq '6.0.0')

{


   # run code set 1


}

else

{


   # run code set 2


}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
1 Reply
LucD
Leadership
Leadership
Jump to solution

You have to use the -eq operator, like this

$esx = Get-VMHost -Name MyEsx*

If ($esx.Version -eq '6.0.0')

{


   # run code set 1


}

else

{


   # run code set 2


}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos