Splatting - 输入字符串的格式不正确

时间:2017-02-17 15:14:10

标签: arrays powershell hashtable wmi dynamic-programming

我无法通过我的Invoke-WmiMethod命令让我的splatting工作。我像这样声明哈希表:

$HKU = 2147483651

$MyParams = @{
  'Class' = 'StdRegProv';
  'Name' = 'EnumKey';
  'ArgumentList' = "$HKU,''";
  'ComputerName' = '';
}

# additional code determining ComputerName... #

$MyParams['ComputerName'] = $MyComputer;
$Vals = Invoke-WmiMethod @MyParams

这一行给出了以下错误:

Invoke-WmiMethod : Input string was not in a correct format.
At C:\Users\Person\Desktop\tmp.ps1:160 char:20
+         $Vals = Invoke-WmiMethod @MyParams

你知道问题是什么吗?

1 个答案:

答案 0 :(得分:1)

试试这个:

$HKU = 2147483651

$MyParams = @{
  'Class' = 'StdRegProv';
  'Name' = 'EnumKey';
  'ArgumentList' = @($HKU,'');
  'ComputerName' = '';
}

$MyParams['ComputerName'] = $MyComputer;
$Vals = Invoke-WmiMethod @MyParams