# PowerShell Support in Maguyva: Code Graphs for Scripts and Modules

Canonical source: https://maguyva.ai/languages/powershell

License: text under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/); code samples under [MIT-0](https://opensource.org/license/mit-0); the Maguyva name, logos, brand assets and other code are not covered. Details: [maguyva.ai/license](https://maguyva.ai/license).

Maguyva parses PowerShell with AST, symbol, and graph support, so AI agents can follow functions, classes, and cmdlet calls across scripts and modules.

## Support snapshot

- Tier: AST and symbol support
- Shell
- Extensions: .ps1, .psd1, .psm1
- Real AST parsing for syntax-aware search and structural context.
- Named symbols feed semantic lookup and cross-reference. Graph navigation is available when relationship extraction is enabled.
- This language contributes symbols and relationships to graph-aware search; supported edge types vary with its native constructs.
- AST parsing and symbol extraction are both available.

## Best fit

- Infrastructure and operations teams with large `.ps1` and `.psm1` estates whose scripts call each other's functions.
- PowerShell modules built from advanced functions, classes, and enums.
- Automation runbooks where agents need to see which scripts touch a service, a file share, or a registry key before a change.

## Agent workflows

- Find every caller of an advanced function before changing its parameters.
- List which scripts call a cmdlet such as `Restart-Service` before changing a runbook.
- Map which functions write to a shared variable before refactoring a module.

## Where PowerShell trips up shallow AI tools

Your functions and the built-in cmdlets share one naming style. `Get-Invoice` and `Get-ChildItem` look the same, so a tool that drops "built-ins" by verb throws away your own functions too. Scripts also mix module-level code, functions, classes, and script blocks in one file, which makes it hard to tell which function a line belongs to.

Maguyva keeps both kinds of call and attributes each one to the function it sits in.

## What Maguyva extracts in PowerShell

Maguyva covers `.ps1`, `.psm1`, and `.psd1` files. Functions and class methods are extracted as callables, and classes and enums as types. Script and method parameters are tracked, and reads and writes inside a function are attributed to that function rather than to the module.

Cmdlet calls stay in the graph. PowerShell does not apply the standard-library filter that most languages use, so `Write-Host`, `Get-ChildItem`, and `Restart-Service` appear as call edges next to your own `Get-*` and `Set-*` functions. An agent can ask which scripts restart a service, or which functions write to the console, and get a structural answer.

No relationship type is marked not applicable for PowerShell, so the graph also records class inheritance and interface implementation, instantiation, control flow, and reads and writes.

## Example agent prompts

- "Who calls `Invoke-Backup`, and from which scheduled scripts?" (`find_symbol`, then `dependency_search` incoming)
- "Which functions call `Restart-Service`?" (`dependency_search`)
- "Trace what `Deploy-Site` does from start to finish." (`get_task_context`)

## Known limits

- Because cmdlet calls are kept, very common ones such as `Write-Host` and `Select-Object` have a large number of incoming edges. Start from your own function when you want a focused call graph.
- `Import-Module` and dot-sourcing are ordinary commands, so the `imports` preset in `structural_search` selects nothing. Use `text_pattern_search` to list them.

## Next steps

Connect a repository with the [quickstart](/docs/quickstart), then check the support matrix on the [compatibility page](/docs/compatibility). For .NET code that your scripts call, read the [C# guide](/languages/csharp).

## Engine details

- PowerShell support covers `.ps1`, `.psm1`, and `.psd1`. Functions and class methods are callables, and classes and enums are types.
- The standard-library filter is off for PowerShell, so cmdlet calls such as `Get-ChildItem` stay in the graph beside your own functions.
- Reads and writes inside a function are attributed to that function rather than to the module.

## Useful MCP entry points

- `find_symbol`: Use it for an advanced function or class when you need the definition and callers.
- `dependency_search`: Use incoming traversal on a cmdlet such as `Restart-Service` to see which scripts call it.
- `get_task_context`: Use it for prompts like “trace what `Deploy-Site` does from start to finish.”
