Question

It seems that most common commands are gone when using workflow sessions in 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

What can I do to make all the common commands normally available in workflows available through a session?

Was it helpful?

Solution

Since you are working with a workflow session, you will want to put your commands in a workflow.

$session = New-PSWorkflowSession -ThrottleLimit 3

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

For more info, check out PowerShell Workflows: Restrictions and High Level Architecture of Windows PowerShell Workflow (Part 1)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top