Splatting - Input string was not in a correct format

我只是一个虾纸丫 提交于 2019-12-11 06:32:55

问题


I can't seem to get my splatting to work in my Invoke-WmiMethod command. I declare the hash table like so:

$HKU = 2147483651

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

# additional code determining ComputerName... #

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

This line gives me the following error:

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

Do you know what the problem could be?


回答1:


Try this:

$HKU = 2147483651

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

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


来源:https://stackoverflow.com/questions/42301329/splatting-input-string-was-not-in-a-correct-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!