我开始使用PowerShell,并且正在'库'文件中创建函数以提高可读性,然后从我的'worker'脚本。如何在使用'使用PowerShell运行'执行PowerShell脚本时在另一个PowerShell脚本中调用函数
=================== Library file ==========================
function ShowMessage($AValue)
{
$a = new-object -comobject wscript.shell
$b = $a.popup($AValue)
}
=================== End Library file ==========================
=================== Worker file ==========================
. {c:\scratch\b.ps1}
ShowMessage "Hello"
=================== End Worker file ==========================
运行“工人”在PowerShell的IDE时,但是当我用鼠标右键单击该工作人员文件,并选择它无法找到函数“使用PowerShell运行”脚本正常工作“ShowMessage”。这两个文件都在同一个文件夹中。这里可能会发生什么?
另请注意,使用`&`调用脚本,例如。 `&“c:\ scratch \ b.ps1”`不会导入这些函数。 – ashes999 2017-08-10 21:57:11