如果我有一个具有以下功能的 .ps1 文件
function SomeFunction {}
function AnotherFunction {}
Run Code Online (Sandbox Code Playgroud)
如何获取所有这些函数的列表并调用它们?
我想做这样的事情:
$functionsFromFile = Get-ListOfFunctions -Path 'C:\someScript.ps1'
foreach($function in $functionsFromFile)
{
$function.Run() #SomeFunction and AnotherFunction execute
}
Run Code Online (Sandbox Code Playgroud) powershell ×1