目的是爲了驗證它傳遞到一定Powershell的功能,以避免以下的錯誤之前的參數是否可以執行:如何驗證是否可以使用Powershell執行路徑?
& : The term 'c:\helloworld' 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 that the path is correct and try again.
At C:\functions\function.ps1:67 char:9
+ & $createServiceCommand install $serviceName
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (c:\helloworld:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
將'helloworld'改爲commandPath後'C:\ Chocolatey \ lib \ chocolatey.0.9.8.24 \ tools \ chocolateyInstall \ NuGet.exe'執行這個腳本會導致'找到命令'。按原樣運行該腳本會導致'找不到命令'。這回答了這個問題。謝謝。我會接受並讚揚答案。 – 030