| name | powershell-windows |
| description | PowerShell scripting rules for Windows environment. Use when running shell commands, Docker operations, or HTTP requests on Windows PowerShell. |
PowerShell Windows — Scripting Rules
Core Principles
1. Command Separation
2. Path Quoting
3. Script Execution
4. Docker Commands
5. HTTP Requests
6. Waiting/Delays
- Wrong:
timeout 10
- Correct:
Start-Sleep -Seconds 10
7. JSON Handling
8. Process Checking
9. Docker Operations
10. Error Handling
Common Errors and Fixes
| Error | Cause | Fix |
|---|
&& is not recognized | Running Windows PowerShell 5.1 | Use ; only for independent commands; use $LASTEXITCODE for conditional chaining |
curl behaves unexpectedly | Windows PowerShell alias / executable resolution differs | Use Invoke-WebRequest, or call curl.exe explicitly when its CLI semantics are required |
timeout behaves unexpectedly | Console utility semantics differ from shell sleep | Use Start-Sleep |
Path not found | Missing quotes on spaced path | Wrap path in double quotes |
Correct Command Examples
# Change directory and execute command
cd "D:\My Projects\MyApp"; ./gradlew clean build -x test
# Wait and make HTTP request
Start-Sleep -Seconds 10; Invoke-WebRequest -Uri "http://localhost:9090/status" -UseBasicParsing
# Docker operations
docker-compose -f "D:\My Projects\MyApp\docker-compose.yml" down
docker-compose -f "D:\My Projects\MyApp\docker-compose.yml" build --no-cache
docker-compose -f "D:\My Projects\MyApp\docker-compose.yml" up -d
# Check server status
$response = Invoke-WebRequest -Uri "http://localhost:9090/status" -UseBasicParsing
$json = $response.Content | ConvertFrom-Json
Write-Host "Transport: $($json.mcp.transport)"