Skip to content

Synchronous Execution

Chamoswor edited this page Oct 19, 2025 · 4 revisions

Single command

from virtualshell import Shell

with Shell() as sh:
    r = sh.run("Get-Process | Select-Object -First 1 Name")
    assert r.success

Batch

from virtualshell import Shell

with Shell() as sh:
    rs = sh.run(["Get-Date", "Get-Random", "Get-Location"])  # List[ExecutionResult]
    for r in rs:
        if not r.success:
            print("failed:", r.err)

Clone this wiki locally