invoke_dbatools_command
Run dbatools PowerShell commands for SQL Server administration, returning structured JSON output with safety confirmations for destructive actions.
Instructions
Execute a dbatools command via PowerShell and return structured JSON output.
SAFETY: For any destructive or change command (Remove, Drop, Disable, Reset, etc.), always explain the consequences to the user and ask for explicit confirmation before running. Only proceed with confirm:true if the user has clearly confirmed their intent. Respect DBATOOLS_SAFE_MODE: never bypass safety checks. For any command that modifies or deletes data, double-check with the user before proceeding. Show the exact command and output for transparency. Non-readonly commands require confirm:true when safe mode is enabled.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| commandName | Yes | Exact dbatools command name to execute, e.g. Get-DbaDatabase | |
| parameters | No | Key-value map of parameters. Strings, numbers, and booleans map directly to PowerShell parameters. For SQL authentication pass SqlCredential as an object: { "username": "sa", "password": "secret" }. Example: { "SqlInstance": "localhost,2022", "SqlCredential": { "username": "sa", "password": "P@ssw0rd" } } | |
| confirm | No | Set to true to allow execution of change/destructive commands (required when safeMode is on) | |
| selectProperties | No | List of property names to select from the output (e.g. ['Name', 'Status', 'SizeMB']). Use this to reduce output size for commands that return complex objects like SMO database or login objects. When omitted, all properties are returned. |