VMware Cloud Community
priyawiz
Contributor
Contributor

What would be the last service that starts on a VMware that says the VM is online

Hi All,

I have been using a powershell script that changes the CPU and Memory of any given VM.

The code has blocks below

COnnect to VC

Get VM view

CHeck Vmware tools status

Power off the VM

Change the CPU and Mem

Power oN the VM and wait for vmware tools OK.

The problem here is after powering on the vm the tools are showing OK and the script ends if anyother script runs for any change it fails to power off the vm stating the tools not running and we found that after the vM powered On the vmware tools flips ttwice or thrice from Ok to not running on VC and settles up.

Is there any other service I can look up for where If i get Ok with that particular status I can proceed with any change. (Assuring this would defenitely mean that vmware tools are stable)

Any help is appreciated.

Thanks,

Priya

0 Kudos
6 Replies
RParker
Immortal
Immortal

usually if the tools start, that pretty much indicates the system is up. There are no other services that would signify "online"

0 Kudos
LucD
Leadership
Leadership

Depends what you are looking for.

Are you checking if the machine is online then you could check if significant service is started

Get-Service -ComputerName <hostname> ...

Depending which environment your guest is running in (standalone, Active Directory...) you can check a specific service.

But that doesn't guarantee you of course that the VMware Tools are running.

____________

Blog: LucD notes

Twitter: lucd22


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

0 Kudos
RvdNieuwendijk
Leadership
Leadership

The VMware Tools are running as the "VMware Tools Service". You can check if this service is started with something like this:

$ToolsStatus = (Get-Service "VMware Tools Service" -Computername YourVMname).Status
If ($ToolsStatus -eq "Running") {
...
}

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
LucD
Leadership
Leadership

I'm not sure that is a good criteria to decide if the machine is "online".

Wouldn't for example the "Net Logon" service be a better indicator ?

____________

Blog: LucD notes

Twitter: lucd22


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

0 Kudos
RvdNieuwendijk
Leadership
Leadership

I don't know which of the services "Vmware Tools Service" or "Net logon" is started first. As the VMware Tools are needed to run other scripts and the Net logon service to be able to logon to the server, it might be a good practice to check for both services:

$ToolsStatus = (Get-Service "VMware Tools Service" -Computername YourVMname).Status
$NetlogonStatus = (Get-Service "Net logon" -Computername YourVMname).Status
If ($ToolsStatus -eq "Running" -and $NetlogonStatus -eq "Running") {
...
}

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
priyawiz
Contributor
Contributor

Thanks guys for getting back so quickly..

This is what I was doing

$vminfo = Get-View -ViewType VirtualMachine -Filter @{"Name" = $VMname}

$vmguest= $vminfo.Summary

$vmGuest= $vmguest.Guest

and get the $vmGuest.ToolsStatus status to see toolsOk. However it looks like after the poweron of the VM the Tools were ok after say 30 secs and went off and came OK and went off again.. Thats a pretty strange that it flipped thrice and settled on...

When my script found tools ok it issued a shutdown and it failed stating tools not running as the VM was flipping it happened everytime so its not one time. I would also try the netlogon service however I believed so far that tools was the last service and looks like was wrong at that...

Thanks,

Priya

0 Kudos