[英]Unable to load .ps1 powershell script from Powershell command (console)
我陷入了這個奇怪的問題,我試圖從powershell命令提示符下執行powershell腳本。 但是我既沒有得到任何錯誤,也沒有加載腳本。
我在C:\\temp\\myFunction.ps1
有腳本(它具有方法getMyName()
)
我打開powershell命令並導航到該目錄並執行
./myFunction.ps1
則沒有錯誤,然后返回到提示的下一行。 但是,當我嘗試調用函數getMyName時-出現錯誤,無法識別getMyName。
我已將Execution-Policy to Unrestricted
設置Execution-Policy to Unrestricted
,我以管理員身份運行powershell
嘗試點源您的腳本:
. .\myFunction.ps1
這是Powershell腳本的基本問題。 設置物理保存文件的路徑,然后執行Powershell腳本。 還有一件事
1. start your command window run as admin.
2. set the Powershell script policy for execution.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.