I would like to use a certain expression/property in a if statement, and also want to list a certain output. I simply don't know how to use these further down the script.
$tools = Get-VM | select name, @{N=”ToolsStatus”; E={$_.Extensiondata.Summary.Guest.ToolsStatus}}
[string]$Output = ""
foreach ($vm in $vmtools){
$Output = $Output + "$($vm.name) ----- $($vm.ToolsVersion)`n"
}
if ("ToolsStatus" -eq "toolsOld") {
Write-Output "CRITICAL, These VM's have out of date tools: `n $Output"
$Status = 2 enter code here
- How do I go about using "ToolStatus"/E={$_.Extensiondata.Summary.Guest.ToolsStatus}} in my if statement?
- I know that i can use $vm.name to list the names, but let's say I wanted to have the output from @{N=”ToolsStatus”; E={$_.Extensiondata.Summary.Guest.ToolsStatus}} as well?