使用函数而不是脚本块运行 spacepool 作业

runspacepool job with a function rather than a script block

我有一个场景,我想在 powershell 模块中放置一个函数,然后在一种情况下加载模块并循环调用该函数,但在另一种情况下我想加载模块并使用使用运行空间并行运行。但是,据我所知,我既不能将函数作为值分配给变量,也不能使用函数创建作业。 这是正确的吗,我只需要在两个地方维护代码,在一个脚本中作为函数,在另一个脚本中作为脚本块,或者我是否缺少替代方案?

Function Get-Example
{
    Write-Verbose -Verbose "This is an example"
}

$block = (Get-Command Get-Example).ScriptBlock
Start-Job -ScriptBlock $block