Automation

 View Only
  • 1.  Where clause question

    Posted Sep 13, 2016 08:07 PM

    Hello,

    I'm reviewing a script I found that returns guest information and whether hot add is enabled:

    Get-VM | Get-View | Select Name, `

    @{N="CpuHotAddEnabled";E={$_.Config.CpuHotAddEnabled}}, `

    @{N="CpuHotRemoveEnabled";E={$_.Config.CpuHotRemoveEnabled}}, `

    @{N="MemoryHotAddEnabled";E={$_.Config.MemoryHotAddEnabled}}

    How would I limit this to show where CpuHotAddEnabled = false ?

    When I pipe the above to a where I receive "The property 'CpuHotAddEnabled' cannot be found on this object"

    Thanks.



  • 2.  RE: Where clause question
    Best Answer

    Posted Sep 14, 2016 04:48 AM

    Try like this

    Get-VM | Get-View |

    where{$_.Config.CpuHotAddEnabled -ne $true} |

    Select Name,

    @{N="CpuHotAddEnabled";E={$_.Config.CpuHotAddEnabled}},

    @{N="CpuHotRemoveEnabled";E={$_.Config.CpuHotRemoveEnabled}},

    @{N="MemoryHotAddEnabled";E={$_.Config.MemoryHotAddEnabled}}



  • 3.  RE: Where clause question

    Posted Sep 14, 2016 12:25 PM

    Thank You LucD, I was thinking in SQL I guess!!!