简体   繁体   中英

“Invoking” Powershell workflow from a script

I am pretty new to Powershell and Powershell Workflows. In all the Workflow examples I've seen on the internet, the workflow is "defined" and "invoked" from the same file, like below:

workflow test-workflow {
    $random = 1
    $random
}

test-workflow

This is a pretty lame example where the workflow simply prints the value "1". What I want to do is define the workflow in a file called say "test-workflow.ps1" and invoke it from another Powershell script file called say "test-script.ps1". Is that possible?

Dot-source the script with the workflow implementation in your other script:

. C:\path\to\workflow.ps1

Test-Workflow

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM