powershell "& 'C:\path\to\file.ps1 arg1 arg2 arg3 arg4'"
arg4 是一个 HashTable。这可行吗?
powershell "& 'C:\path\to\file.ps1 arg1 arg2 arg3 arg4'"
arg4 是一个 HashTable。这可行吗?
假设有一个这样的脚本 (foo.ps1):
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