Automation

 View Only
  • 1.  VMTools Install Status Script

    Posted May 02, 2016 06:50 PM

    Hey all,

    I am currently trying to make a script to report any VMs that do not have tools installed, but it is kicking back all my veeam replicas and that is just not needed.  Here is my script, what am I doing wrong to eliminate any VMs with the suffix _replica.  Here is my script:

    Get-VM | Get-View | Select-Object @{N=”VM Name”;E={$_.Name}},@{Name=”VMware Tools”;E={$_.Guest.ToolsStatus}}

    Get-View -ViewType VirtualMachine -Property Name,Guest.ToolsStatus -Filter @{

      "Config.Template"="False";"Guest.ToolsStatus"="^(?!toolsOk$).*$" } | `Select-Object Name,@{Name="ToolsStatus";E={$_.Guest.ToolsStatus}} |

    I have excluded some information before this for the vcenter connection and after because I FTP this to a web server.

    Any help would be great, thank you!

    Andy



  • 2.  RE: VMTools Install Status Script

    Posted May 02, 2016 08:36 PM

    Does this work for you ?

    Get-View -ViewType VirtualMachine -Property Config.Template,Name,Guest.ToolsStatus -Filter @{

      "Config.Template"="False";"Guest.ToolsStatus"="^toolsOk";"Name"="^((?!_replica).)*$"} |

    Select-Object Name,@{Name="ToolsStatus";E={$_.Guest.ToolsStatus}} 

    Since negative matching and RegEx is not too straightforward, in the end you might pick the more simple solution

    Get-View -ViewType VirtualMachine -Property Config.Template,Name,Guest.ToolsStatus -Filter @{

      "Config.Template"="False";"Guest.ToolsStatus"="^toolsOk"} |

    where{$_.Name -notmatch "_replica$"} |

    Select-Object Name,@{Name="ToolsStatus";E={$_.Guest.ToolsStatus}} 



  • 3.  RE: VMTools Install Status Script
    Best Answer

    Posted May 03, 2016 02:23 PM

    That works to exclude the _replica VMs, but there seems to be an error with the way your filtered for ToolsOk.  The output error only showed VMs with ToolsOK. So I edited it a little to this:

    Get-View -ViewType VirtualMachine -Property Config.Template,Name,Guest.ToolsStatus -Filter @{

      "Config.Template"="False";"Guest.ToolsStatus"="^(?!toolsOk$).*$" ;"Name"="^((?!_replica).)*$"} |

    Select-Object Name,@{Name="ToolsStatus";E={$_.Guest.ToolsStatus}}

    This worked, thank you so much!



  • 4.  RE: VMTools Install Status Script

    Posted May 03, 2016 05:15 PM

    Oops, misread that, thought you wanted the VMs with ToolsOk.