我運行Windows 7 RTM。 Powershell 2.0默認安裝。我使用優秀的Windows Powershell ISE來編輯我的腳本。我有以下腳本:PowerShell 2.0中帕拉姆關鍵字錯誤
Param($p)
Param($d)
echo $p $d
我將腳本另存爲SayItAgain.ps1。當我嘗試從交互式shell像這樣運行此腳本:
./SayItAgain -p "Hello"
我收到以下錯誤:
The term 'Param' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling o
f the name, or if a path was included, verify that the path is correct and try again.
At C:\users\cius\Code\powershell\SayItAgain.ps1:2 char:6
+ Param <<<< ($destination)
+ CategoryInfo : ObjectNotFound: (Param:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
這是一個已知的問題還是我只是用錯了?
我想知道,如果實際錯誤在腳本的不同行上。你說你在呼喚./SayItAgain.ps1但錯誤說你叫FindAndCopyFiles.ps1。有沒有更多的代碼可以分享?有時候錯誤可能會指向錯誤的方向。錯誤可能在其他地方。 – 2009-08-22 05:22:55
啊,我對此不一致表示歉意。我創建了SayItAgain作爲一個簡單的例子來追蹤問題。我複製了原始腳本中的錯誤錯誤。我將在我的附錄中解釋這一點。 – 2009-08-22 15:42:16