How can I convert a hashtable to an array of strings? Suppose $l_table is a hashtable. If I try
$l_array = $l_table | format-table
then $l_arra
This is a common problem; Hashtable must be retrieved by either keys or values but you can't get a collection of pairs - that is what the original hashtable is, after all. In my example, the hashtable is represented by a "Dictionary" (you will remember from VBS :-). However you will need to determine a separator to delimit keys & values, in this case "Key<->Value"
$ARRAY = ( $DICT.Keys | foreach-object { "$_<->$($DICT[$_])"})
You can even sort the keys first if you want. In this case I reversed to Value<--->Key and sorted by values. I've also expanded the string a little to make more verbose but legible:
$ARRAY = ( $DICT.Keys | foreach-object { $DICT[$_] + "<--->" + $_} | sort-object)