Skip to content

Running Scripts

Chamoswor edited this page Oct 19, 2025 · 2 revisions

Positional args

from virtualshell import Shell

with Shell() as sh:
    res = sh.script("./scripts/do_stuff.ps1", args=["arg1", "arg2"])

Named args

from virtualshell import Shell

with Shell() as sh:
    res = sh.script("./scripts/do_stuff.ps1", args={"Name": "World", "Count": "5"})

Dot‑sourcing (mutates session state)

from virtualshell import Shell

with Shell() as sh:
    res = sh.script("./scripts/profile.ps1", dot_source=True)

Async scripts

from virtualshell import Shell

with Shell() as sh:
    fut = sh.script_async("./scripts/do_stuff.ps1", args={"Path": "."})
    print(fut.result().out)

Clone this wiki locally