我有这个让我抓狂的问题:
我有一个功能
function xyz
{
foreach($x in $input)
{
}
}
1..10 | xyz
这保存在文件 test.ps1 中。当我每次写它时像“.\test.ps1”一样执行它
cmdlet Write-Output at command pipeline position 1
Supply values for the following parameters:
InputObject[0]:
为什么会这样?如果我喜欢它是行不通的
$myArray = @("a","b","c")
xyz -arr $myArray
并做一个像
function xyz
{
param(
[string[]]$arr
)
foreach($x in $arr)
{
}
}
为什么?