将哈希表转换为字符串数组 [英] Converting hashtable to array of strings
问题描述
如何将哈希表转换为字符串数组?假设 $l_table 是一个哈希表.如果我尝试
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
那么 $l_array 是一个数组,而是一个FormatEntryData"对象的数组.如果我这样做
then $l_array is an array, but an array of "FormatEntryData" objects. If I do
[string[]]$l_array = $l_table | format-table
然后 $l_array 是一个字符串数组,但字符串都是Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData".如果我尝试
then $l_array is an array of strings, but the strings are all "Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData". If I try
$l_array = $l_table | out-string
然后 $l_array 是单个字符串.我尝试了很多其他的东西,但没有任何效果,除了手动循环,我真的不想这样做.
then $l_array is a single string. I've tried lots of other things, but nothing works, short of manually looping through, which I really don't want to do.
推荐答案
[string[]]$l_array = $l_table | out-string -stream
这篇关于将哈希表转换为字符串数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!