Automation

 View Only
  • 1.  VM Tools Status Report with more Infos than the status

    Posted Feb 02, 2011 04:25 PM

    Hallo.

    I'm searching for a script that shows me the VM Tools Status like "Tools Version", "Tools running oder not" and "Tools need upgrade" for each vm. I found a little script

    $date=get-date -uformat "%Y%m%d-%H%M%S"; get-vm | % { get-view $_.ID } | select Name,

    @{ Name="ToolsStatus"; Expression={$_.guest.toolsstatus}},

    @{ Name="ToolsVersion"; Expression={$_.config.tools.toolsVersion}} |

    sort-object name | export-csv c:\temp\vmtoolsver_$date.txt -NoTypeInformation

    but i need additional information like Custom Fields for each VM named "Customer".

    Can everyone help me to implement such information in the script?

    That would be very nice.

    Thanks to all.

    Best regards

    ron9999



  • 2.  RE: VM Tools Status Report with more Infos than the status

    Posted Feb 02, 2011 05:44 PM

    Hi Ron,

    I have adapted your script to also return the value of the customer custom field:

    $date = Get-Date -uformat "%Y%m%d-%H%M%S"
    Get-VM | Get-View | `
    Select-Object -Property Name, 
    @{ Name="ToolsStatus"; Expression={$_.guest.toolsstatus}}, 
    @{ Name="ToolsVersion"; Expression={$_.config.tools.toolsVersion}},
    @{ Name="Customer"; Expression={
      (Get-Annotation -Entity (Get-VIObjectByVIView -VIView $_) -CustomAttribute Customer).Value}} | `
    Sort-Object -Property Name | Export-CSV -Path c:\temp\vmtoolsver_$date.txt -NoTypeInformation
    
    

    Regards, Robert



  • 3.  RE: VM Tools Status Report with more Infos than the status

    Posted Feb 03, 2011 08:56 AM

    Hi Robert.

    Thanks for helping me.

    I have tried the script but the Annotation field is empty although it is filled in the environment. I tried some other annotation fields but with same results.

    Have you an idea why the fields are empty?

    Regards

    Ron



  • 4.  RE: VM Tools Status Report with more Infos than the status

    Posted Feb 03, 2011 09:23 AM

    Hi Ron,

    it might be that you are using an older PowerCLI version. The latest version is 4.1 U1. You can check your version with the Get-PowerCLIVersion cmdlet. If you do:

    Get-VM | Get-Annotation
    
    

    You should get all the custom fields of all your virtual machines.

    Regards, Robert



  • 5.  RE: VM Tools Status Report with more Infos than the status

    Posted Feb 03, 2011 09:56 AM

    Hi Robert.

    With Get-PowerCLIVersion I got

    VMware vSphere PowerCLI 4.1 U1 build 332441.

    With Get-VM | Get-Annotation I can see all fiels including the filled values. That is a little bit strange why this isn't working inside the script.

    Regards

    Ron



  • 6.  RE: VM Tools Status Report with more Infos than the status

    Posted Feb 03, 2011 10:04 AM

    Hi Ron,

    the only thing left that I can think of is that the name of custom attribute "Customer" is written different. Maybe you can try with another custom atribute by changing the value behind the -CustomAttribute parameter in the script.

    Regards, Robert



  • 7.  RE: VM Tools Status Report with more Infos than the status

    Posted Feb 03, 2011 11:05 AM

    Hi Robert,

    I tried another attribute but the result was the same. I have no idea what the reason for this behavior is.

    Regards

    Ron



  • 8.  RE: VM Tools Status Report with more Infos than the status

    Posted Feb 03, 2011 05:18 PM

    Hi Ron,

    I made a new version of the script that does basicly the same but doesn't use the Get-View and Get-VIObjectByVIView cmdlets. Can you give it a try?

    $date = Get-Date -uformat "%Y%m%d-%H%M%S"
    Get-VM | `
    Select-Object -Property Name, 
    @{ Name="ToolsStatus"; Expression={
      $_.ExtensionData.Guest.ToolsStatus}}, 
    @{ Name="ToolsVersion"; Expression={
      $_.ExtensionData.Config.Tools.ToolsVersion}},
    @{ Name="Customer"; Expression={
      (Get-Annotation -Entity $_ -CustomAttribute Customer).Value}} | `
    Sort-Object -Property Name | `
    Export-CSV -Path c:\temp\vmtoolsver_$date.txt -NoTypeInformation
    
    

    Regards, Robert



  • 9.  RE: VM Tools Status Report with more Infos than the status
    Best Answer

    Posted Feb 03, 2011 05:24 PM

    And another solution is using the CustomFields property of the VM object:

    $date = Get-Date -uformat "%Y%m%d-%H%M%S"
    Get-VM | `
    Select-Object -Property Name, 
    @{ Name="ToolsStatus"; Expression={
      $_.ExtensionData.Guest.ToolsStatus}}, 
    @{ Name="ToolsVersion"; Expression={
      $_.ExtensionData.Config.Tools.ToolsVersion}},
    @{ Name="Customer"; Expression={$_.CustomFields["Customer"]}} | `
    Sort-Object -Property Name | `
    Export-CSV -Path c:\temp\vmtoolsver_$date.txt -NoTypeInformation
    
    



  • 10.  RE: VM Tools Status Report with more Infos than the status

    Posted Feb 04, 2011 02:21 PM

    Hello Robert.

    Thanks for both scripts. Both solutions generate the required information. That was very helpfull.

    Thank you.

    Regards

    Ron