Powershell
Remote PowerShell (WinRM) for swamp.
invoke runs any script block on a remote Windows computer with
Invoke-Command, optionally inside a named session configuration, and
stores the output (formatted text plus the objects as JSON) as a versioned
result resource.
Scripts are templates. Each {{name}} placeholder is filled from the
variables map and inserted as a single-quoted PowerShell literal, so a
value can hold any text without changing the command around it.
PowerShell runs locally through a configurable executable: pwsh by
default, or powershell.exe on Windows. Credentials come from a vault and
reach PowerShell over stdin, never on the command line; the password is
never stored in results.
On Linux (including WSL) and macOS, pwsh also needs the PSWSMan WSMan client, Kerberos/NTLM GSSAPI support and domain DNS. The README walks through the full setup and how to verify it.
Quick Start
swamp extension pull @tagur/powershell
swamp vault create local_encryption powershell
printf '%s' 'EXAMPLE\admin' | swamp vault put powershell USERNAME
read -s P && printf '%s' "$P" | swamp vault put powershell PASSWORD
swamp model create @tagur/powershell ps
# globalArguments:
# executable: pwsh
# authentication: Negotiate
# username: ${{ vault.get("powershell", "USERNAME") }}
# password: ${{ vault.get("powershell", "PASSWORD") }}
swamp model @tagur/powershell method run invoke ps \
--input computerName=server01.example.com \
--input 'script=Get-Service -Name {{svc}}' \
--input 'variables={"svc":"WinRM"}'Global Arguments
| Argument | Type | Description |
|---|---|---|
| executable? | string | Local PowerShell executable that runs Invoke-Command: pwsh, or |
| username? | string | User for -Credential, e.g. DOMAIN\\user or user@domain. Omit to use |
| password? | string | Password for username. Reference a vault: |
| authentication? | enum | Invoke-Command -Authentication mechanism |
| useSSL? | boolean | Connect over HTTPS (WinRM port 5986) |
| port? | number | WinRM port override |
| timeoutSeconds? | number | Kill the local PowerShell process after this many seconds |
| Argument | Type | Description |
|---|---|---|
| computerName | string | Remote computer passed to -ComputerName |
| configurationName? | string | Session configuration passed to -ConfigurationName |
| script | string | Script block body. {{name}} placeholders are replaced with quoted |
| variables? | record | Values for the {{name}} placeholders in script |
| name? | string | Data instance name for the result. Defaults to a slug of |
Resources
- Has README or module doc2/2earned
- README has a code example1/1earned
- README is substantive1/1earned
- Most symbols documented1/1earned
- No slow types (deprecated)1/1earned
- Dependencies pass trust audit2/2earned
- Has description1/1earned
- Platform support declared (or universal)2/2earned
- License2/2earned
- Verified public repository2/2earned
Spawns a subprocess with Deno.Command().
- models/powershell.ts:308 — no reason given