drivera01
Enthusiast
Enthusiast

vmwaretool state off/on

Jump to solution

Is there a way to query if vmwaretools is running?

I was hoping I could get it from:

get-VM | Select Name ToolsVersionStatus but it  does not give me what I need.

I need to know when it is "not running"/"running"

what im trying to do it

....

...

...



Start-VM -VM $myvm

do { IS VMWARETOOL running?  if not than sleep a bit till it starts


} until  ( is vmwaretools running? ...yes) ...continue on....
            

update-tools -NoReboot .......

. (vmware tools needs to be running.. this is why I'm asking.

..

..

...

..

Excuse the prehistoric excuse for code... As you can see I am a green as the kermit the frog when it comes to powercli. but im trying....


0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

First you can have a look what the status of the VMware Tools is on your VM with something like

Get-VM | Select Name,@{N="Tools Status";E={$_.ExtensionData.Guest.toolsVersionStatus2}}

You can use the same property in a Where-clause, and take action for spacific states of the tools.

Something like this

Get-VM | 
Where {$_.ExtensionData.Guest.toolsVersionStatus2 -eq "guestToolsNeedUpgrade"} |
Update-Tools -NoReboot

The possible values of the property are listed in VirtualMachineToolsVersionStatus


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

View solution in original post

0 Kudos
5 Replies
LucD
Leadership
Leadership

First you can have a look what the status of the VMware Tools is on your VM with something like

Get-VM | Select Name,@{N="Tools Status";E={$_.ExtensionData.Guest.toolsVersionStatus2}}

You can use the same property in a Where-clause, and take action for spacific states of the tools.

Something like this

Get-VM | 
Where {$_.ExtensionData.Guest.toolsVersionStatus2 -eq "guestToolsNeedUpgrade"} |
Update-Tools -NoReboot

The possible values of the property are listed in VirtualMachineToolsVersionStatus


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

0 Kudos
drivera01
Enthusiast
Enthusiast

Thank you LucD,

looks much better than the circus I was creating!!!

0 Kudos
drivera01
Enthusiast
Enthusiast

Hi LucD,

The example you gave gives the state of the vmwaretools (needs upgrade..etc...), but does not show if it is running or not. Can that even be done?

So what im getting at is: lets say I put toether a script that many things. and lets say powering up a vm followed by updating vmwareools is done.

The updating of vmwaretools will fail if the vm is not fully powered up and the vmwaretool driver is not running yet. This is why I was wondering if there was a way to query that like you see in vcenter.

the only way I can think of solving it is by placing a long sleep between actions, this seems to be a hack solution but I may have to do that...

0 Kudos
LucD
Leadership
Leadership

Try like this

Get-VM | Select Name, 
@{N="Tools Status";E={$_.ExtensionData.Guest.toolsVersionStatus2}},
@{N="Tools Running State";E={$_.ExtensionData.Guest.toolsRunningStatus}}

That toolsRunningStatus property should allow you to test if the VMware Tools are running.


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

0 Kudos
raffic_ncc
Enthusiast
Enthusiast

Thanks much for the information...

Mohammed Raffic VCP4,VCP5,VCAP4-DCA,VCAP5-DCA,VCP-Cloud, MCSA.MCTS,CCA http://www.vmwarearena.com
0 Kudos