run_powershell
Execute PowerShell commands safely using structured JSON definitions to run single commands, .NET methods, pipelines, or command sequences.
Instructions
Executes PowerShell commands based on a structured JSON definition.
This tool allows you to run PowerShell commands safely strings.
It expects a JSON string that defines the command(s), parameters, pipelines, and sequences.
Args:
json: A JSON string defining the command structure.
Structure examples:
1. Single Command:
[{"command": "Get-Item", "parameters": ["."]}]
2. .NET Static Method:
[{"command": "[System.Math]::Sqrt", "parameters": [16]}]
# Generates: [System.Math]::Sqrt(16)
3. Command with Named Parameters:
[{"command": "Get-Item", "parameters": {"-Path": "."}}]
4. Pipeline:
[{"command": "Get-Process", "then": {"command": "Select-Object", "parameters": ["Name"]}}]
5. Sequence (Multiple commands):
[{"command": "mkdir", "parameters": ["test"]}, {"command": "cd", "parameters": ["test"]}]
Returns:
The standard output of the executed PowerShell command(s), or an error message if execution fails.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| json | Yes |