Suppose I have a hash table with a list of virtual machine names. I also have an array variable containing virtual machine objects and all of their properties. I want to cycle through the array variable and remove all of the virtual machine names that do not exist in the hash table. How would I accomplish this?
Thanks
If your array is called $inArray and your hash table is called $hashTab, you could do something like this
$outArray = $inArray | %{ if($hashTab.ContainsKey($_.VMName)){ $_ } }
$outArray = $inArray | %{
if($hashTab.ContainsKey($_.VMName)){
$_
}
The selected objects will in array $outArray.
OK great thanks again