1. PowerShell 기본 명령어 모음

PowerShell 명령어(Cmdlet)는 대부분 동사-명사 형식을 사용한다.

1-1. 파일 & 폴더 관련

명령어 별칭(Alias) 설명 예시
Get-ChildItem ls, dir 현재 위치의 파일·폴더 목록 출력 Get-ChildItem C:\Users
Set-Location cd 디렉토리 이동 Set-Location D:\Projects
Copy-Item cp 파일·폴더 복사 Copy-Item file.txt backup.txt
Move-Item mv 파일·폴더 이동 Move-Item file.txt D:\Backup
Remove-Item rm, del 파일·폴더 삭제 Remove-Item test.txt
New-Item - 새 파일·폴더 생성 New-Item newfile.txt

1-2. 시스템 관리

명령어 설명 예시
Get-Process 현재 실행 중인 프로세스 목록 보기 Get-Process
Stop-Process 특정 프로세스 종료 Stop-Process -Name notepad
Get-Service 서비스 상태 확인 Get-Service
Start-Service 서비스 시작 Start-Service -Name Spooler
Stop-Service 서비스 중지 Stop-Service -Name Spooler

1-3. 검색 & 필터링

명령어 설명 예시
Select-String 파일에서 특정 문자열 검색 Select-String -Path "log.txt" -Pattern "error"
Where-Object 조건에 맞는 데이터 필터링 `Get-Process
Sort-Object 결과 정렬 `Get-ChildItem
Select-Object 특정 컬럼만 선택 `Get-Process

1-4. 출력 & 변수

# 출력
Write-Output "Hello, PowerShell!"

# 변수 선언
$name = "유준상"
$age = 27
Write-Output "이름: $name, 나이: $age"

1-5. 파이프라인 (Pipeline)

• 기호로 앞 명령의 결과를 다음 명령으로 전달

# 프로세스 목록에서 메모장만 필터링
Get-Process | Where-Object { $_.ProcessName -like "*note*" }

1-6. 실행 정책 (스크립트 실행 허용)

# 현재 실행 정책 확인
Get-ExecutionPolicy

# 로컬 스크립트 실행 허용
Set-ExecutionPolicy RemoteSigned

2. PowerShell 스크립트 구조

PowerShell 스크립트 파일 확장자는 .ps1 이다.