Hi
Can some one help me on this below code.
After executing this script its not showing output in correct format.
$resourcepool = 'testresp01','testresp02'
$respExpression = "^$($resourcepool -join '$|^')$"
foreach($resp in (Get-View -ViewType ResourcePool -Filter @{'Name'=$respExpression})){
$vmsinresp=Get-View -Id $resp.Vm
$vmtoolsoutdate=$vmsinresp|? {$_.guest.toolsversionstatus -eq "guestToolsNeedUpgrade"}
#$vmsinresp=Get-View -ViewType VirtualMachine -Property Name,runtime.powerState,Guest.GuestFullName,Config.GuestFullName,Config.Hardware.Device,Config.version,guest.toolsVersion,guest.toolsversionstatus -SearchRoot ($resp).MoRef
$vmtoolsoutdate| select @{N="VM";E={$vmtoolsoutdate.name}},
@{N='powerState';E={$vmtoolsoutdate.runtime.powerState}},
@{N='IP';E={[string]::Join(',',($vmtoolsoutdate.Guest.Net | %{$_.IpAddress | where{$_.Split('.').Count -eq 4} | %{$_}}))}}
}
Sample Output:
VM powerState IP
-- ---------- --
{test347, test353, test349,test327...} {poweredOn, poweredOn, poweredOn, poweredOn...} 153.71.2.43,153.71.2.49,153.71.2.45,153.71.2...