Passing Hashes to a Powershell function problem

后端 未结 2 783
时光取名叫无心
时光取名叫无心 2021-01-28 17:18

I must be missing something. i have to variables: $var1 and $var2

$var1 | gm 
 TypeName: System.Collections.Hashtable

Each of them has IP and Por

2条回答
  •  再見小時候
    2021-01-28 18:16

    When you use parentheses, PowerShell constructs an array with all the values in it, and uses that as the value for one parameter.

    So, CompareData ($var1, $var2) is equivalent to CompareData -data1 @($var1, $var2) with no value specified for the -data2 parameter.

    If you use CompareData -data1 $var1 -data2 $var2 as suggested by @dwillits you should get the result you expect.

提交回复
热议问题