본문으로 건너뛰기
Skillpedia
일반 코딩48k · #5482

powershell-windows

하는 일

이 가이드는 Windows PowerShell 스크립트를 올바르고 안전하게 작성하는 방법을 알려 줍니다. 괄호를 올바르게 쓰기, 특수 문자 피하기, 사용하기 전에 무언가가 존재하는지 확인하기 등 흔한 오류를 피하는 중요한 규칙을 보여 줍니다.

사용하는 경우

  • ✓PowerShell 스크립트 작성을 배우는 중일 때.
  • ✓스크립트에서 예상치 못한 오류가 발생할 때.
  • ✓스크립트가 여러 컴퓨터에서 잘 작동하도록 하고 싶을 때.

스킬 링크

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

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/powershell-windows/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“PowerShell 스크립트에서 ‘or’와 함께 괄호를 올바르게 쓰려면 어떻게 해야 하나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

가이드는 PowerShell 규칙을 설명합니다. 특정 상황에서 괄호가 필요하다는 점과, 기본(ASCII) 문자만 쓰는 것이 중요하다는 점을 포함합니다. 또한 변수를 쓰기 전에 값이 있는지 확인하는 방법도 보여 줍니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 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.
자주 묻는 질문

스크립트에 이모지나 특수 문자를 쓸 수 없는 이유는 무엇인가요?

PowerShell 스크립트는 기본 영문이 아닌 문자(ASCII가 아닌 문자)를 이해하는 데 어려움을 겪을 수 있습니다. ASCII 문자만 쓰면 어떤 컴퓨터에서도 이상한 오류 없이 작동합니다.

‘널 확인’이란 무엇이며 왜 중요한가요?

상자가 비어 있는지 확인하고 나서 무언가를 꺼내는 것과 같습니다. 존재하지 않는(‘널’인) 것을 쓰려고 하면 스크립트가 멈출 수 있습니다. 먼저 확인하면 이런 오류를 막을 수 있습니다.

PowerShell은 오류를 어떻게 처리하나요?

오류가 발생하면 모든 것을 멈추도록('Stop'), 오류가 있어도 계속하도록('Continue'), 예상되는 오류는 무시하도록('SilentlyContinue') 설정할 수 있습니다. 또한 실행을 시도하고 오류가 나면 잡아내는 방법('Try/Catch')도 있습니다.

상세 정보

작성자의 원본 설명

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

repo: sickn33/agentic-awesome-skills

인기도

GitHub 스타
48k
순위
#5482
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬