. .\Variables.ps1 返回 CommandNotFound

. .\Variables.ps1 返回 CommandNotFound

我试图将一个名为“Variables.ps1”的 powershell 脚本中的变量 $company 调用到同一文件夹中另一个名为“edit_website.ps1”的 powershell 脚本中,该脚本位于“edit_website.ps1”的顶部,. .\variables.ps1然后稍后在脚本中调用“$company”,但它没有返回任何内容,这让我认为变量没有被加载。运行“edit_website”脚本时,它返回“无法识别术语‘.\variables.ps1’”有人能解释一下这是为什么吗?

答案1

通过将 ./variables 替换为 powershell 脚本的精确路径来解决。

相关内容