在使用cmd.exe调用时,PowerShell中是否有一种方法可以将HashTable作为参数传递?
我想调用这样的脚本:
powershell "& 'C:\path\to\file.ps1 arg1 arg2 arg3 arg4'"
Run Code Online (Sandbox Code Playgroud)
其中arg4是HashTable.这可能吗?
Kei*_*ill 13
给出一个像这样的脚本(foo.ps1):
param($a1, $a2, $a3, [hashtable]$a4)
"a1 is $a1"
"a2 is $a2"
"a3 is $a3"
"a4 is "
$a4
Run Code Online (Sandbox Code Playgroud)
您可以从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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2973 次 |
| 最近记录: |