7
我有腳本文件獲取-ProcesWithParam.ps1作爲執行PowerShell腳本文件,它是一個字符串值
param(
$name
)
function List-Process($name)
{
Write-Host "Process List"
get-process -name $name
#get-process
}
List-Process -name $name
在另一個腳本中,我得到這個文件名作爲字符串變量
$scriptFile = Get-ExecFile # returns "C:\Get-ProcesWithParam.ps1"
#execute the script
# ... other code ...
問題是我需要執行這個文件(通過以文件的參數以及!)
我試圖調用命令
invoke-command -scriptblock { param($name) $scriptFile -name $name } -ArgumentList "chrome"
但它沒有工作,它只是打印文件名我怎麼能執行文件,那裏的字符串變量$ stringFile?
哇......我試過很多其他的事情,但是這個作品:)! – JeeZ 2011-05-27 08:22:26