2

在 powershell 中使用工作流会话时,似乎大多数常用命令都消失了:

PS P:\> $session = New-PSWorkflowSession -ThrottleLimit 3
PS P:\> Invoke-Command $session {Write-Output "test"}

The term 'Write-Output' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included,
verify that the path is correct and try again.
 + CategoryInfo         : ObjectNotFound: (Write-Output:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
+ PSComputerName        : localhost

我可以做些什么来使工作流中通常可用的所有常用命令通过会话可用?

4

1 回答 1

0

由于您正在使用工作流会话,因此您需要将命令放入工作流中。

$session = New-PSWorkflowSession -ThrottleLimit 3

Invoke-Command $session {
        workflow test {
            Write-Output -Input "test"
        }
        test
    }

有关详细信息,请查看PowerShell 工作流:Windows PowerShell 工作流的限制高级架构(第 1 部分)

于 2014-04-23T14:17:51.890 回答