win10 現在默認策略為 Restricted
該策略情況下是禁止在終端下運行腳本文件的,所以我們想要通過powershell 來運行我們的腳本文件的話就需要我們更改其策略才行,如下命令可以幫助你(記得以管理員身份打開 powershell)
# 查看當前執行策略 get-executionpolicy # 更改執行策略為 RemoteSigned Set-ExecutionPolicy RemoteSigned
然后再試試?不行的話重新打開 powershell 就好了
關於執行策略可以詳看官方的文檔 https://docs.microsoft.com/zh-cn/powershell/module/microsoft.powershell.security/set-executionpolicy?view=powershell-6