2013-05-15 33 views
0

我無法通過此錯誤消息。如何獲得「hello world」腳本從powershell中的命令行運行?

感謝

The term 'power-date.ps1' is not recognized as the name of a cmdlet, function, script file 
, or operable program. Check the spelling of the name, or if a path was included, verify t 
hat the path is correct and try again. 
At line:1 char:15 
+ power-date.ps1 <<<< 
    + CategoryInfo   : ObjectNotFound: (power-date.ps1:String) [], CommandNotFound 
    Exception 
    + FullyQualifiedErrorId : CommandNotFoundException 
除非你使用前綴與他們
+0

你有一個名爲'power-date.ps1'的'.ps1'文件嗎? – Bill

+0

是的,我在不同的位置。只是爲了確保我可以從命令行找到它,因爲Windows不喜歡空白區域 – user2386748

+0

我不確定'windows不喜歡空白區域'是什麼意思。 Windows在沒有問題的情況下處理命令中的空格,並且在很長一段時間內完成了這些操作。 –

回答

5

的PowerShell不會運行在當前目錄下的腳本.\如:

.\power-date.ps1 

這是一個安全功能,防止有人掉落一個腳本調用DIR或者ls到黑客可以訪問的目錄中,並且用戶經常進入。黑客的意圖是,當用戶執行dir時,假的dir.ps1將被用戶調用爲最不知名的。此安全功能可防止此類攻擊。如果用戶想要調用腳本dir.ps1,則必須通過路徑明確引用它。 .\dir.ps1