Use PowerCLI to Get Log File When Tools are Broken

Use PowerCLI to Get Log File When Tools are Broken

Over the past weekend we had a massive push of VMware Tools and VM hardware updates.  For the most part this push was smooth except for 2 machines.  Of course these 2 machines are high priority development machines and rebuild just won’t work.

Trying to get a log file off a machine that doesn’t allow for the drivers to  install becomes when trying to research the issue.  It’s difficult to read a massive log file on a 800×600 resolution screen.

VMTools Installed OptionsVMTools Installed Options

PowerCLI to Read the Log File

With having a portion of VM tools installed, I wrote a simple invoke-vmscript to see if I’m able to leverage PowerCLI to get into the VM to read the log into a variable to write it back to my workstation.

$test = Invoke-VMScript -VM VM_Name -ScriptType Powershell -ScriptText "Get-Content C:\Users\Administrator\AppData\Local\Temp\vminst.log" -GuestCredential (Get-Credential)
$test.ScriptOutput | out-file C:\scripts\logs\vminst.log

I already know the location to where the log file is being wrote, %temp%.     So I can have PowerCLI read the file via the Get-Content command then store it as the $test variable.  Then wrote the log file to my local workstation in the C:\scripts\logs directory and save it as vminst.log.  As simple as this was it worked like a charm.

The Issue with the VMware Tools Installation

The odd issue with the Tools installation is that I had 2 servers with the same symptoms.  At first, I didn’t believe it was a Windows issue, as we pushed Tools to nearly 800 VMs that day of varies Windows versions.  Of all of the VMs these 2 were the only ones to have any issues.

VMware Tools Installation Error VMCI

Reading the log file didn’t really point to a problem other than the some RPC errors.  One of my colleagues found the following KB article, https://kb.vmware.com/s/article/2111936, that started us down the correct path.

Resolution

On the problem server I ran Powershell to get the status of the service, found that it wasn’t running, and started it.

DeviceInstall Window Service

After verify that the service was running, I ran the tools install once more.  Which it ran just fine.

-Stuart

Leave a Reply

Your email address will not be published. Required fields are marked *