Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
cmd.exe powershell哈希表_Powershell_Cmd - Fatal编程技术网

cmd.exe powershell哈希表

cmd.exe powershell哈希表,powershell,cmd,Powershell,Cmd,当使用cmd.exe调用时,PowerShell中是否有方法将哈希表作为参数传递 我想调用如下脚本: powershell "& 'C:\path\to\file.ps1 arg1 arg2 arg3 arg4'" param($a1, $a2, $a3, [hashtable]$a4) "a1 is $a1" "a2 is $a2" "a3 is $a3" "a4 is " $a4 其中arg4是哈希表。这可能吗 唯一想到的是将哈希表保存为xml,并将文件名传递给它。给定如下脚本

当使用cmd.exe调用时,PowerShell中是否有方法将哈希表作为参数传递

我想调用如下脚本:

powershell "& 'C:\path\to\file.ps1 arg1 arg2 arg3 arg4'"
param($a1, $a2, $a3, [hashtable]$a4)

"a1 is $a1"
"a2 is $a2"
"a3 is $a3"
"a4 is "
$a4

其中arg4是哈希表。这可能吗

唯一想到的是将哈希表保存为xml,并将文件名传递给它。

给定如下脚本(foo.ps1):

powershell "& 'C:\path\to\file.ps1 arg1 arg2 arg3 arg4'"
param($a1, $a2, $a3, [hashtable]$a4)

"a1 is $a1"
"a2 is $a2"
"a3 is $a3"
"a4 is "
$a4
您可以从cmd.exe调用它,例如指定哈希表作为第四个参数:

C:\> powershell -command "& {c:\foo.ps1 1 2 three @{name='John';age=45}}"
a1 is 1
a2 is 2
a3 is three
a4 is

Name                           Value
----                           -----
name                           John
age                            45