Saltar al contenido
Skillpedia
Programación general48 mil · #5482

powershell-windows

Qué hace

Esta guía te enseña a escribir scripts de Windows PowerShell de forma correcta y segura. Muestra reglas importantes para evitar errores comunes, como usar bien los paréntesis, evitar caracteres especiales y comprobar que algo existe antes de usarlo.

Cuándo usarla

  • ✓Cuando estás aprendiendo a escribir scripts de PowerShell.
  • ✓Si tus scripts dan errores inesperados.
  • ✓Para asegurarte de que tus scripts funcionan bien en distintos ordenadores.

Link de la skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/powershell-windows/SKILL.md

Cópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.

Cómo usar

La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.

Mensaje listo para pegar

Usa esta skill para ayudarme: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/powershell-windows/SKILL.md Lee el archivo SKILL.md de ese link y sigue sus instrucciones en mi tarea.
¿Quieres que tu IA encuentre skills como esta por sí sola?Instala el MCP gratis de Skillpedia: una línea, y busca entre 15.000+ skills antes de cada tarea.Instalar en 1 minuto →

Ejemplo de qué pedirle a la IA

“¿Cómo uso correctamente los paréntesis en un script de PowerShell con 'or'?”

5 skills nuevas por semana. 1 minuto de lectura.

Cómo funciona

La guía explica las reglas de PowerShell, como cuándo necesitas paréntesis y la importancia de usar solo caracteres sencillos (ASCII). También muestra cómo comprobar si una variable tiene valor antes de intentar usarla.

Contenido técnico (SKILL.md original)

Texto original del autor, en inglés, directo de GitHub.

PowerShell Windows Patterns

Critical patterns and pitfalls for Windows PowerShell.


1. Operator Syntax Rules

CRITICAL: Parentheses Required

❌ Wrong ✅ Correct
if (Test-Path "a" -or Test-Path "b") if ((Test-Path "a") -or (Test-Path "b"))
if (Get-Item $x -and $y -eq 5) if ((Get-Item $x) -and ($y -eq 5))

Rule: Each cmdlet call MUST be in parentheses when using logical operators.


2. Unicode/Emoji Restriction

CRITICAL: No Unicode in Scripts

Purpose ❌ Don't Use ✅ Use
Success ✅ ✓ [OK] [+]
Error ❌ ✗ 🔴 [!] [X]
Warning ⚠️ 🟡 [*] [WARN]
Info ℹ️ 🔵 [i] [INFO]
Progress ⏳ [...]

Rule: Use ASCII characters only in PowerShell scripts.


3. Null Check Patterns

Always Check Before Access

❌ Wrong ✅ Correct
$array.Count -gt 0 $array -and $array.Count -gt 0
$text.Length if ($text) { $text.Length }

4. String Interpolation

Complex Expressions

❌ Wrong ✅ Correct
"Value: $($obj.prop.sub)" Store in variable first

Pattern:

$value = $obj.prop.sub
Write-Output "Value: $value"

5. Error Handling

ErrorActionPreference

Value Use
Stop Development (fail fast)
Continue Production scripts
SilentlyContinue When errors expected

Try/Catch Pattern

  • Don't return inside try block
  • Use finally for cleanup
  • Return after try/catch

6. File Paths

Windows Path Rules

Pattern Use
Literal path C:\Users\User\file.txt
Variable path Join-Path $env:USERPROFILE "file.txt"
Relative Join-Path $ScriptDir "data"

Rule: Use Join-Path for cross-platform safety.


7. Array Operations

Correct Patterns

Operation Syntax
Empty array $array = @()
Add item $array += $item
ArrayList add `$list.Add($item)

8. JSON Operations

CRITICAL: Depth Parameter

❌ Wrong ✅ Correct
ConvertTo-Json ConvertTo-Json -Depth 10

Rule: Always specify -Depth for nested objects.

File Operations

Operation Pattern
Read `Get-Content "file.json" -Raw
Write `$data

9. Common Errors

Error Message Cause Fix
"parameter 'or'" Missing parentheses Wrap cmdlets in ()
"Unexpected token" Unicode character Use ASCII only
"Cannot find property" Null object Check null first
"Cannot convert" Type mismatch Use .ToString()

10. Script Template

# Strict mode
Set-StrictMode -Version Latest
$ErrorActionPreference = "Continue"

# Paths
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path

# Main
try {
    # Logic here
    Write-Output "[OK] Done"
    exit 0
}
catch {
    Write-Warning "Error: $_"
    exit 1
}

Remember: PowerShell has unique syntax rules. Parentheses, ASCII-only, and null checks are non-negotiable.

When to Use

This skill is applicable to execute the workflow or actions described in the overview.

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
Preguntas frecuentes

¿Por qué no puedo usar emojis o caracteres especiales en los scripts?

PowerShell puede tener problemas para interpretar caracteres que no son del inglés básico (ASCII). Usar solo caracteres ASCII asegura que tu script funcione en cualquier ordenador sin errores extraños.

¿Qué es la 'comprobación de nulos' y por qué es importante?

Es como revisar si una caja está vacía antes de sacar algo de ella. Si intentas usar algo que no existe (es 'null'), tu script puede fallar. Comprobarlo antes evita estos errores.

¿Cómo gestiona PowerShell los errores?

Puedes indicarle que se detenga cuando ocurra un error ('Stop'), que continúe aunque haya errores ('Continue') o que ignore los errores que esperas que ocurran ('SilentlyContinue'). También existe una forma de intentar ejecutar algo y capturar los errores si aparecen ('Try/Catch').

Detalles

Descripción original del autor

PowerShell Windows patterns. Critical pitfalls, operator syntax, error handling.

repo: sickn33/agentic-awesome-skills

Popularidad

Estrellas en GitHub
48 mil
Posición en el ranking
#5482
Licencia
MIT
Actualizada
15/10/2026

¿Te sirve esta skill?

0

Entra para votar.

Comentarios

  • …

Más skills de este repositorio

Skills parecidas