You can specify that the ESXi should be in a "connected" state
$esx = Get-Datastore xxxxx | Get-VMHost -State Connected
if($esx){
$rEsx = $esx | Get-Random
....
}
If $esx is empty, the code block following the If-statement will not be executed.
You can specify that the ESXi should be in a "connected" state
$esx = Get-Datastore xxxxx | Get-VMHost -State Connected
if($esx){
$rEsx = $esx | Get-Random
....
}
If $esx is empty, the code block following the If-statement will not be executed.