I am using this parameter to randomly select hosts in a cluster, but I want to be able to exclude a specific host, how would I do this?
Here is the string:
$esx = Get-VMHost -Location $vccluster | Get-Random
What code would I append Get-Random with to exclude a specific host which I have defined as a variable $VMHost
Thanks
Try with
$esx = Get-VMHost -Location $vccluster | where{$_.Name -ne $VMHost} | Get-Random
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try with
$esx = Get-VMHost -Location $vccluster | where{$_.Name -ne $VMHost} | Get-Random
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks LucD - on the Get-Random, how would one create an exception to this to exclude a specific host?
Not sure what you mean.
The exception is done via the Where-clause, unless you mean something else.
The Get-Random cmdlet doesn't have an Exclude option
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Sorry - working on too many things at once, you already answered this it is what the post was about hahaha not sure what I was thinking.... if at all 🙂