我有一个非常简单的 Powershell v1.0 脚本来按名称杀死进程:
$target = $args[0]
get-process | where {$_.ProcessName -eq $target} | stop-process -Force
哪个有效。然而,当我刚刚
get-process | where {$_.ProcessName -eq $args[0]} | stop-process -Force
它不会找到任何进程。那么为什么需要将参数复制到局部变量中才能使代码正常工作呢?