一個腳本塊我想你不能只是這樣做:參數傳遞給在PowerShell中
$servicePath = $args[0]
if(Test-Path -path $servicePath) <-- does not throw in here
$block = {
write-host $servicePath -foreground "magenta"
if((Test-Path -path $servicePath)) { <-- throws here.
dowork
}
}
因此,如何能我通過我的變量到腳本塊$塊?
你將與你的腳本塊做什麼?使用調用命令或&? – 2013-05-02 21:06:32
如果你打算使用'&',那麼你可以這樣做:'&{param($ hello)$ hello} -hello world' – JohnL 2013-05-02 21:09:59
@LarsTruijens - 我打算做Invoke-Command -Session – dexter 2013-05-03 14:25:20