使用我的以下代码,Write-Host 似乎以一种奇怪的方式输出变量(至少对我来说来自 C#)。
代码在这里
function Run(
[string] $command,
[string] $args
)
{
Write-Host 'from function - command is:' $command '.args is: ' $args
}
$cmd = "ping"
$args = "208.67.222.222"
Write-Host 'from main - command is:' $cmd '.args is: ' $args
Run("ping","208.67.222.222")
输出在这里
from main - command is: ping .args is: 208.67.222.222
from function - command is: ping 208.67.222.222 .args is:
正如我所料,如何Write-Host
从 main 工作,但在函数内它同时输出所有变量?我该如何纠正这种行为?