home / skills / windmill-labs / windmill / write-script-powershell
/system_prompts/auto-generated/skills/write-script-powershell
This skill helps you write PowerShell scripts by illustrating parameter declarations, typing, and structured return values for clear, reusable automation.
npx playbooks add skill windmill-labs/windmill --skill write-script-powershellReview the files below or copy the command above to add this skill to your agents.
---
name: write-script-powershell
description: MUST use when writing PowerShell scripts.
---
## CLI Commands
Place scripts in a folder. After writing, run:
- `wmill script generate-metadata` - Generate .script.yaml and .lock files
- `wmill sync push` - Deploy to Windmill
Use `wmill resource-type list --schema` to discover available resource types.
# PowerShell
## Structure
Arguments are obtained by calling the `param` function on the first line:
```powershell
param($Name, $Count = 0, [int]$Age)
# Your code here
Write-Output "Processing $Name, count: $Count, age: $Age"
# Return object
@{
name = $Name
count = $Count
age = $Age
}
```
## Parameter Types
You can specify types for parameters:
```powershell
param(
[string]$Name,
[int]$Count = 0,
[bool]$Enabled = $true,
[array]$Items
)
@{
name = $Name
count = $Count
enabled = $Enabled
items = $Items
}
```
## Return Values
Return values by outputting them at the end of the script:
```powershell
param($Input)
$result = @{
processed = $true
data = $Input
timestamp = Get-Date -Format "o"
}
$result
```
This skill teaches how to write PowerShell scripts that integrate with the Windmill/wmill platform and how to prepare them for deployment. It covers parameter declaration, typing, structured return values, and the CLI steps to generate metadata and push scripts. The guidance focuses on predictable inputs/outputs so scripts run reliably as webhooks, tasks, or UI-driven actions.
Scripts declare inputs with a param(...) block on the first line so the runtime can pass arguments in reliably. You can annotate parameter types (string, int, bool, array) and set defaults, which improves validation and UX in automation platforms. Return structured objects by outputting a hashtable or object at the end of the script; Windmill captures that output as the script result. After authoring, use the CLI to generate metadata and deploy so the platform can expose the script as a resource.
How do I declare optional parameters?
Set a default value in the param block, e.g. [int]$Count = 0. Parameters with defaults are optional.
How should I return data from the script?
Output a hashtable or PSCustomObject at the end of the script. The platform captures the final output as the result.
What CLI steps are required to deploy a script?
Run wmill script generate-metadata to create metadata and lock files, then wmill sync push to deploy the script.