相关疑难解决方法(0)

从脚本中获取函数列表

如果我有一个具有以下功能的 .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

4
推荐指数
1
解决办法
7214
查看次数

标签 统计

powershell ×1