PowerCLI

 View Only
  • 1.  VMware Tools Status where Open VM Tools is installed

    Posted Jun 20, 2023 08:19 AM

    Hi,

    I am using the below script to get the VMware Tools Info. We have Windows and Linux Servers. On Linux Servers we have installed Open VM Tools, even when the open vm tools are installed and running, I am seeing output as unmanaged on Linux VMs.

    Please help!!

    Script

    Get-Folder | Get-VM | Select @{N="Folder";E={$_.Folder.Name}},
    Name,
    @{N="IP Address";E={$_.guest.IPAddress[0]}},
    @{N="VM PowerState";E={@($_.PowerState)}},
    @{N="OS"; E={@($_.guest.OSFullName)}},
    @{N="VM_Hardware_Ver"; E={@($_.HardwareVersion)}},
    #@{N='Tools Version';E={$_.Guest.ToolsVersion}},
    @{N="Tools_Status";E={$_.ExtensionData.Guest.ToolsStatus}},
    @{N="Tools_State";E={$_.ExtensionData.Guest.GuestState}},
    @{N="Tools_Version";E={$_.ExtensionData.Config.Tools.ToolsVersion}},
    @{N="Tools Status";E={
    if($_.Guest.Extensiondata.GuestState -eq "notRunning"){
    "Not running" }
    else{
    $_.Guest.Extensiondata.ToolsVersionStatus.Replace("guestToolsNeedUpgrade","Out of date").Replace("guestToolsNotInstalled","Not installed").Replace("guestToolsCurrent","Current").Replace("guestToolsUnmanaged","Unmanaged")
    }
    }} | Export-Excel -Path $reportlocation -WorksheetName VM_Tools_Info

    ganapa2000_0-1687249050831.png

     

     

     

     



  • 2.  RE: VMware Tools Status where Open VM Tools is installed

    Posted Jun 20, 2023 09:20 AM

    Not sure what the problem is, the ToolsVersionnStatus and ToolsVersionStatus2 are from the point of view of VMware Tools.

    The ToolsInstallType clearly says that the Open VMware Tools are installed.



  • 3.  RE: VMware Tools Status where Open VM Tools is installed

    Posted Jun 20, 2023 10:38 AM

    LucD, the script works fine if VMware Tools are installed. But for Linux based VMs, where Open VM Tools is installed, it shows as unmanaged even though Open VM Tools are installed and running

    ganapa2000_0-1687257460510.png

     

     



  • 4.  RE: VMware Tools Status where Open VM Tools is installed

    Posted Jun 20, 2023 11:15 AM

    As I said earlier, those ToolsVersionStatus and ToolsVersionStatus2 properties are only useful when you have VMware Tools installed.
    You will first have to check ToolsInstallType, then select the correct properties.



  • 5.  RE: VMware Tools Status where Open VM Tools is installed

    Posted Jun 20, 2023 01:13 PM

    LucD,

    I modified as below. but how can I check and change the status of Linux VMs to Running, Not Running or Unmanaged

    Get-Folder | Get-VM | Select @{N="Folder";E={$_.Folder.Name}},
    Name,
    @{N="IP Address";E={$_.guest.IPAddress[0]}},
    @{N="VM PowerState";E={@($_.PowerState)}},
    @{N="OS"; E={@($_.guest.OSFullName)}},
    @{N="VM_Hardware_Ver"; E={@($_.HardwareVersion)}},
    @{N="Tools_Status";E={$_.ExtensionData.Guest.ToolsStatus}},
    @{N="Tools_State";E={$_.ExtensionData.Guest.GuestState}},
    @{N="Tools_Version";E={$_.ExtensionData.Config.Tools.ToolsVersion}},
    @{N="ToolsInstallType";E={$_.ExtensionData.Guest.ToolsInstallType}},
    @{N="ToolsUpgradePolicy";E={$_.ExtensionData.Config.Tools.ToolsUpgradePolicy}},
    @{N="Extended_Tools_Status";E={
    if($_.ExtensionData.Guest.ToolsInstallType -eq "guestToolsTypeOpenVMTools*" -and $_.Guest.Extensiondata.GuestState -eq "notRunning"){
    "Not Running"
    }else{
    $_.Guest.Extensiondata.ToolsVersionStatus.Replace("guestToolsNeedUpgrade","Out of date").Replace("guestToolsNotInstalled","Not installed").Replace("guestToolsCurrent","Current").Replace("guestToolsUnmanaged","Unmanaged")
    }
    }} | Export-Excel -Path $reportlocation -AutoFilter -AutoSize -BoldTopRow -FreezeTopRow -WorksheetName Prod_VM_Tools_Info

     

     



  • 6.  RE: VMware Tools Status where Open VM Tools is installed

    Posted Jun 20, 2023 08:48 PM

    You will have to a command inside the Guest OS.
    Something like 

    vmtools-service status


  • 7.  RE: VMware Tools Status where Open VM Tools is installed

    Posted Jun 21, 2023 10:40 AM

    LucD,

    how can I modify the below line and capture the status.

    If $_.ExtensionData.Guest.ToolsInstallType -eq "guestToolsTypeOpenVMTools*" then I would like to capture the status of $_.Guest.Extensiondata.GuestState

     

    @{N="Extended_Tools_Status";E={
    if($_.ExtensionData.Guest.ToolsInstallType -eq "guestToolsTypeOpenVMTools*" -and $_.Guest.Extensiondata.GuestState -eq "notRunning"){
    "Not Running"
    }else{
    $_.Guest.Extensiondata.ToolsVersionStatus.Replace("guestToolsNeedUpgrade","Out of date").Replace("guestToolsNotInstalled","Not installed").Replace("guestToolsCurrent","Current").Replace("guestToolsUnmanaged","Unmanaged")
    }

     

     



  • 8.  RE: VMware Tools Status where Open VM Tools is installed

    Posted Jun 21, 2023 11:48 AM

    Like I said before you will have to query inside the Guest OS (Invoke-VMScript) for that info.



  • 9.  RE: VMware Tools Status where Open VM Tools is installed

    Posted Jun 21, 2023 12:39 PM

    LucD,

    I am able to fix as below, let me know, if any changes needs to done.

    $foundRunning = $false

    Get-Folder | Get-VM | Select @{N="Folder";E={$_.Folder.Name}},
    Name,
    @{N="IP Address";E={$_.guest.IPAddress[0]}},
    @{N="VM PowerState";E={@($_.PowerState)}},
    @{N="OS"; E={@($_.guest.OSFullName)}},
    @{N="VM_Hardware_Ver"; E={@($_.HardwareVersion)}},
    @{N="Tools_Status";E={$_.ExtensionData.Guest.ToolsStatus}},
    @{N="Tools_State";E={$_.ExtensionData.Guest.GuestState}},
    @{N="Tools_Version";E={$_.ExtensionData.Config.Tools.ToolsVersion}},
    @{N="ToolsInstallType";E={$_.ExtensionData.Guest.ToolsInstallType}},
    @{N="ToolsUpgradePolicy";E={$_.ExtensionData.Config.Tools.ToolsUpgradePolicy}},

    @{N="Extended_Tools_Status";E={
    if($_.Guest.ExtensionData.ToolsInstallType -like "guestToolsTypeOpenVMTools*" -and $_.Guest.Extensiondata.ToolsRunningStatus -eq "guestToolsRunning"){
    "Running"
    $foundRunning = $true
    }elseif(!$foundRunning){
    $_.Guest.Extensiondata.ToolsVersionStatus.Replace("guestToolsNeedUpgrade","Out of date").Replace("guestToolsNotInstalled","Not installed").Replace("guestToolsCurrent","Current").Replace("guestToolsUnmanaged","Unmanaged")
    }
    }} | Export-Excel -Path $reportlocation